https://leetcode.com/problems/subsets/description/?envType=daily-question&envId=2024-05-24
/**
* @param {number[]} nums
* @return {number[][]}
*/
var subsets = function(nums) {
let res = [[]]
for (let num of nums) {
let n = res.length
for (let i = 0; i < n; i++) {
let curr = [...res[i]]
curr.push(num)
res.push(curr)
}
}
return res
};
Top comments (0)