MCPcopy Create free account
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / getSums

Function getSums

backtracking/target-sum.js:14–18  ·  view source on GitHub ↗
(nums, target)

Source from the content-addressed store, hash-verified

12// Time O(n) - because we are using recursion, at most we will have n calls in the call-stack
13//
14const getSums = (nums, target) => {
15 const result = [];
16 backtrack(0, 0, [], nums, result, target);
17 return result;
18};
19
20function backtrack(idx, currSum, currSumArray, nums, result, target) {
21 if (idx > nums.length || currSum > target) {

Callers 1

target-sum.jsFile · 0.85

Calls 1

backtrackFunction · 0.70

Tested by

no test coverage detected