Skip to content

Commit 8fccb7b

Browse files
committed
Runtime: 113 ms (Top 76.66%) | Memory: 45.7 MB (Top 51.16%)
1 parent 75ceecf commit 8fccb7b

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1+
// Runtime: 113 ms (Top 76.66%) | Memory: 45.7 MB (Top 51.16%)
12
function recursion(index, list, target, res, arr){
23
if(index == arr.length){
34
if(target == 0){
45
res.push([...list]);
56
}
67
return;
78
}
8-
9+
910
if(arr[index] <= target){
10-
11+
1112
list.push(arr[index]);
12-
13+
1314
recursion(index, list, target - arr[index], res, arr);
14-
15+
1516
list.pop();
16-
17+
1718
}
18-
19+
1920
recursion(index + 1, list, target, res, arr);
20-
21+
2122
}
2223
var combinationSum = function(candidates, target) {
2324
let res = [];
2425
recursion(0, [], target, res, candidates);
2526
return res;
26-
};
27+
};

0 commit comments

Comments
 (0)