Please note this solution does not work when nums.size() > 32.

```
vector<int> helper(vector<int>& nums, int magic){
vector<int> rtn = {};
for(int i = 0; i < nums.size(); i++)
if(((1 << i) & magic) != 0) rtn.push_back(nums[i]);
return rtn;
}
vector<vector<int> > subsets(vector<int>& nums) {
sort(nums.begin(), nums.end());
vector<vector<int> > rtn = {};
for(int i = 0; i < (1 << nums.size()); i++) rtn.push_back(helper(nums, i));
return rtn;
}
```