Type an input and write what you think is the output . Each problem is converted to Web Assembly, so any possible input will show the corresponding output. Only correct predictions count.
Locked until you have predicted 3 outputs correctly.
| 1 | void build(const vector<int>& nums, int i, vector<int>& current, |
| 2 | vector<vector<int>>& out) { |
| 3 | |
| 4 | int n = nums.size(); |
| 5 | |
| 6 | if (i == n) { |
| 7 | out.push_back(current); |
| 8 | return; |
| 9 | } |
| 10 | |
| 11 | current.push_back(nums[i]); |
| 12 | build(nums, i + 1, current, out); |
| 13 | current.pop_back(); |
| 14 | |
| 15 | build(nums, i + 1, current, out); |
| 16 | } |
| 17 | |
| 18 | vector<vector<int>> solution(const vector<int>& nums) { |
| 19 | |
| 20 | vector<vector<int>> ans; |
| 21 | vector<int> current; |
| 22 | |
| 23 | build(nums, 0, current, ans); |
| 24 | |
| 25 | return ans; |
| 26 | } |
Names have been stripped. The signature is the only clue you get for free. Compiled as C++20 with the standard headers and using namespace std; already in scope.