Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- vector<vector<int>> subsets(vector<int>& nums) {
- int n = (int) nums.size();
- vector<vector<int>> subsets;
- for(int bitmask = 0; bitmask < (1 << n); bitmask++) {
- vector<int> subset;
- for(int bit = 0; bit < n; bit++) {
- if(bitmask & (1 << bit)) {
- subset.push_back(nums[bit]);
- }
- }
- subsets.push_back(subset);
- }
- return subsets;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement