1.题目
子集 - 力扣(LeetCode)https://leetcode.cn/problems/subsets/
2.思路
3.C++代码实现
class Solution {
public:vector<vector<int>> ret;vector<int> path;vector<vector<int>> subsets(vector<int>& nums) {dfs(nums,0);return ret;}void dfs(vector<int>& nums,int pos){for(int i=pos;i<nums.size();i++){path.push_back(nums[i]);dfs(nums,i+1);path.pop_back();}ret.push_back(path);return;}
};