class Solution {
public:
vector<vector<int> > subsetsWithDup(vector<int>&s) {
// Starttyping your C/C++ solution below
// DO NOTwrite int main() function
set<vector<int> > vv;
vector<int> v;
vector<vector<int> > vvv;
sort(s.begin(),s.end());
helper(vv,v,s,0);
set<vector<int>>::iterator it;
for(it=vv.begin();it!=vv.end();++it){
vvv.push_back(*it);
}
return vvv;
}
voidhelper(set<vector<int> >& vv,vector<int>&v,vector<int>& s,int index){
vv.insert(v);
if(index==s.size())
return;
for(inti=index;i<s.size();++i){
v.push_back(s[i]);
helper(vv,v,s,i+1);
v.pop_back();
}
}
};
Leetcode: Subsets ||
最新推荐文章于 2020-10-14 14:45:18 发布