We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c41515a commit 5047cd2Copy full SHA for 5047cd2
78-subsets.js
@@ -21,3 +21,22 @@ function subsets(nums) {
21
}
22
23
console.log(subsets([1, 2, 3]));
24
+
25
+// another
26
27
+/**
28
+ * @param {number[]} nums
29
+ * @return {number[][]}
30
+ */
31
32
+function subsets(nums) {
33
+ const subs = [[]]
34
+ for (let num of nums) {
35
+ const n = subs.length
36
+ for (let i = 0; i < n; i++) {
37
+ subs.push(subs[i].slice(0))
38
+ subs[subs.length - 1].push(num)
39
+ }
40
41
+ return subs
42
+}
0 commit comments