| 8 | } |
| 9 | |
| 10 | void backtrack(int i, std::vector<int>& currSubset, std::vector<int>& nums, std::vector<std::vector<int>>& res) { |
| 11 | // Base case: if all elements have been considered, |
| 12 | // add the current subset to the output. |
| 13 | if (i == nums.size()) { |
| 14 | res.push_back(currSubset); |
| 15 | return; |
| 16 | } |
| 17 | // Include the current element and recursively explore all paths |
| 18 | // that branch from this subset. |
| 19 | currSubset.push_back(nums[i]); |
| 20 | backtrack(i + 1, currSubset, nums, res); |
| 21 | // Exclude the current element and recursively explore all paths |
| 22 | // that branch from this subset. |
| 23 | currSubset.pop_back(); |
| 24 | backtrack(i + 1, currSubset, nums, res); |
| 25 | } |
no outgoing calls
no test coverage detected