78. 子集
遍历全部,不用终止条件
class Solution {
public:
void backtracking(vector<int>& nums,int startIndex)
{
result.push_back(path);
for(int i=startIndex;i<nums.size();i++)
{
path.push_back(nums[i]);
backtracking(nums,i+1);
path.pop_back();
}
}
vector<vector<int>> subsets(vector<int>& nums) {
backtracking(nums,0);
return result;
}
vector<int> path;
vector<vector<int>> result;
};