题目
dfs
代码语言:javascript复制class Solution {
public:
vector<vector<int>> ans;
vector<int> res;
vector<vector<int>> subsetsWithDup(vector<int>& nums) {
sort(nums.begin(),nums.end());
fun(nums,0);
return ans;
}
void fun(vector<int>& nums,int x)
{
ans.push_back(res);
for(int i=x;i<nums.size();i )
{
if(i!=x&&nums[i]==nums[i-1])
{
continue;
}
res.push_back(nums[i]);
fun(nums,i 1);
res.pop_back();
}
}
};