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 grow(const vector<int>& nums, int i, vector<int>& current, |
| 2 | vector<vector<int>>& out) { |
| 3 | |
| 4 | out.push_back(current); |
| 5 | |
| 6 | int n = nums.size(); |
| 7 | |
| 8 | for (int j = i; j < n; j++) { |
| 9 | |
| 10 | if (j > i && nums[j] == nums[j - 1]) { |
| 11 | continue; |
| 12 | } |
| 13 | |
| 14 | current.push_back(nums[j]); |
| 15 | grow(nums, j + 1, current, out); |
| 16 | current.pop_back(); |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | vector<vector<int>> solution(vector<int> nums) { |
| 21 | |
| 22 | sort(nums.begin(), nums.end()); |
| 23 | |
| 24 | vector<vector<int>> ans; |
| 25 | vector<int> current; |
| 26 | |
| 27 | grow(nums, 0, current, ans); |
| 28 | |
| 29 | return ans; |
| 30 | } |
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.