LeetCode 78. Subsets
class Solution {
public:
vector<vector<int>> ans;
vector<vector<int>> subsets(vector<int>& nums) {
vector<int> res;
ans.push_back(res);
fun(res,nums,0);
return ans;
}
void fun(vector<int> res,vector<int> nums,int n)
{
for(int i=n;i<nums.size();i++)
{
res.push_back(nums[i]);
ans.push_back(res);
fun(res,nums,i+1);
res.pop_back();
}
}
};