class Solution {
public:
vector<vector<int>> res;
vector<int> path;
void dfs(int start, vector<int>& nums) {
res.push_back(path);
for (int i = start; i < nums.size(); i ++ ) {
path.push_back(nums[i]);
dfs(i + 1, nums);
path.pop_back();
}
}
vector<vector<int>> subsets(vector<int>& nums) {
dfs(0, nums);
return res;
}
};
标签:nums,res,back,dfs,vector,子集,path,LeetCode,78
From: https://www.cnblogs.com/hjy94wo/p/16656823.html