Skip to content

Commit 47c7414

Browse files
Subsets vJechsmayr#159 is solved
1 parent c7ab2d1 commit 47c7414

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

‎Backtracking/Algorithms_ToDo.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,4 @@
55
+ Letter Combination of a Phone Number [LeetCode #17](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)
66
+ Generate Parentheses [LeetCode #22](https://leetcode.com/problems/generate-parentheses/)
77
+ Combination Sum [LeetCode #39](https://leetcode.com/problems/combination-sum/)
8-
+ Wildcard Matching [LeetCode #44](https://leetcode.com/problems/wildcard-matching/)
9-
+ N-Queens [LeetCode #51](https://leetcode.com/problems/n-queens/)
8+
+ Wildcard Matching [LeetCode #44](https://leetcode.com/problems/wildcard-matching/)

‎Backtracking/combinationSum.js‎

Whitespace-only changes.

‎Backtracking/subset.js‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const helper = function(ret, temp, index, nums) {
2+
for (let i = index+1; i < nums.length; i++) {
3+
const newTemp = [...temp, nums[i]];
4+
ret.push(newTemp);
5+
helper(ret, newTemp, i, nums);
6+
}
7+
}
8+
9+
var subsets = function(nums) {
10+
// Recursively
11+
const ret = [[]];
12+
helper(ret, [], -1, nums);
13+
return ret;
14+
};
15+
16+
console.log(subsets([1,2,3]))

0 commit comments

Comments
 (0)