Skip to content

Commit 15b326c

Browse files
committed
Time: 0 ms (100%), Space: 55.6 MB (40.64%) - LeetHub
source:1937fcc21d8f065a6da374dfdc54115c6f157646
1 parent 2516074 commit 15b326c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {number[][]}
4+
*/
5+
var subsets = function(nums) {
6+
const result =[];
7+
8+
function dfs(idx, path){
9+
result.push([...path]);
10+
for(let i= idx; i< nums.length;i++){
11+
path.push(nums[i]);
12+
dfs(i+1,path);
13+
path.pop();
14+
15+
}
16+
}
17+
dfs(0,[]);
18+
19+
return result;
20+
21+
22+
};

0 commit comments

Comments
 (0)