bit mask
| 9 | public: |
| 10 | // bit mask |
| 11 | vector<vector<int>> subsets(vector<int>& nums) { |
| 12 | int n = nums.size(), p = 1 << n; |
| 13 | vector<vector<int>> sub(p); |
| 14 | for (int i=0; i<p; i++) { |
| 15 | for (int j=0; j<n; j++) { |
| 16 | if ((i>>j)&1 == 1) { |
| 17 | sub[i].push_back(nums[j]); |
| 18 | } |
| 19 | } |
| 20 | } |
| 21 | return sub; |
| 22 | } |
| 23 | }; |
| 24 | |
| 25 | int main() { |
nothing calls this directly
no outgoing calls
no test coverage detected