Simple C++ solution using sets


#1
vector<vector<int> > Solution::subsetsWithDup(vector<int> &A) {
int n=A.size();
set<vector<int>>final;
for(int i=0;i<(1<<n);i++){
    vector<int>temp;
    for(int j=0;j<=n-1;j++){
        if(i&(1<<j)){
            temp.push_back(A[j]);
        }
    }
    sort(A.begin(),A.end());
    final.insert(temp);
}
vector<vector<int>>v;
for(auto x:final)
    v.push_back(x);
return v;
}