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(vector<int>& nums, int i, vector<vector<int>>& out) { |
| 2 | |
| 3 | int n = nums.size(); |
| 4 | |
| 5 | if (i == n) { |
| 6 | out.push_back(nums); |
| 7 | return; |
| 8 | } |
| 9 | |
| 10 | for (int j = i; j < n; j++) { |
| 11 | swap(nums[i], nums[j]); |
| 12 | build(nums, i + 1, out); |
| 13 | swap(nums[i], nums[j]); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | vector<vector<int>> solution(vector<int> nums) { |
| 18 | |
| 19 | vector<vector<int>> ans; |
| 20 | |
| 21 | build(nums, 0, ans); |
| 22 | |
| 23 | return ans; |
| 24 | } |
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.