MCPcopy Index your code
hub / github.com/betomoedano/JavaScript-Coding-Interview-Questions / find

Function find

arrays/combination-sum.js:69–86  ·  view source on GitHub ↗
(target, currPath, index, candidates, paths)

Source from the content-addressed store, hash-verified

67
68// Time O(2^n) | Space O(n)
69function find(target, currPath, index, candidates, paths) {
70 if (target === 0) {
71 paths.push(currPath.slice());
72 return;
73 } else {
74 while (index < candidates.length && target - candidates[index] >= 0) {
75 find(
76 target - candidates[index],
77 [...currPath, candidates[index]],
78 index + 1,
79 candidates,
80 paths
81 );
82 index++;
83 while (candidates[index - 1] === candidates[index]) index++;
84 }
85 }
86}

Callers 1

combinationSum2Function · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected