Backtracking soln


#1

void backtrack(vector &A,int index,vector<vector> &ans,vector &temp){
ans.push_back(temp);
for(int i=index;i<A.size();i++){
temp.push_back(A[i]);
backtrack(A,i+1,ans,temp);
temp.pop_back();
}
}
vector<vector > Solution::subsets(vector &A) {
vector<vector> ans;
vector temp;
sort(A.begin(),A.end());
backtrack(A,0,ans,temp);
return ans;
}