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 | vector<int> solution(int n) { |
| 2 | |
| 3 | vector<int> ans(n + 1, 0); |
| 4 | |
| 5 | for (int i = 1; i <= n; i++) { |
| 6 | ans[i] = ans[i >> 1] + (i & 1); |
| 7 | } |
| 8 | |
| 9 | return ans; |
| 10 | } |
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.