Skip to content

Commit 06f311d

Browse files
authored
Merge pull request vJechsmayr#161 from sun-fox/patch-1
Added 78. Subsets solution "Closes vJechsmayr#159"
2 parents ae96270 + b48143d commit 06f311d

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var subsets = function (nums) {
2+
if (!nums.length) return [[]];
3+
4+
const n = nums.pop();
5+
const sets = subsets(nums);
6+
const sol = [...sets];
7+
for (const s of sets) {
8+
const temp = Array.from(s);
9+
temp.push(n);
10+
sol.push(temp);
11+
}
12+
return sol;
13+
};

0 commit comments

Comments
 (0)