MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / findTargetSumWays

Function findTargetSumWays

javascript/0494-target-sum.js:9–19  ·  view source on GitHub ↗
(nums, target, index = 0, sum = 0)

Source from the content-addressed store, hash-verified

7 * @return {number}
8 */
9var findTargetSumWays = (nums, target, index = 0, sum = 0) => {
10 const isBaseCase = index === nums.length;
11 if (isBaseCase) {
12 const isTarget = sum === target;
13 if (isTarget) return 1;
14
15 return 0;
16 }
17
18 return dfs(nums, target, index, sum); /* Time O(2^N) | Space O(HEIGHT) */
19};
20
21var dfs = (nums, target, index, sum) => {
22 const left = findTargetSumWays(

Callers 1

dfsFunction · 0.70

Calls 5

calculateFunction · 0.85
dfsFunction · 0.70
initTabuFunction · 0.70
searchFunction · 0.70
getTabuFunction · 0.70

Tested by

no test coverage detected