| 12 | //vector is a Dynamic Data structure similar to array but unlike array we do not need to declare its size in advance |
| 13 | |
| 14 | void helper(vector <int> A,vector<int>temp, int i){ |
| 15 | if (i==A.size()){ //Base Case |
| 16 | ans.push_back(temp); //this will keep the contents of temp in ans for now |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | temp.push_back(A[i]); //Appends or adds element at the end |
| 21 | helper(A,temp,i+1); //Inclusion or Take condition |
| 22 | |
| 23 | temp.pop_back(); //Removes an element from the end |
| 24 | helper(A,temp,i+1); //Exclusion or not-take condition |
| 25 | |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | vector<vector<int> > subsets(vector<int>& A) |
| 30 | { |