codekofi
← All problems

Problem 6

Easy30 XP

1 · Worked examples

0 / 3

Give it an input and say what you think comes back. It compiles and runs for real, so a wrong guess still shows you the answer — probe as much as you like. Only correct predictions count.

solution()
returns

2 · Which problem is it?

Locked until you have predicted 3 outputs correctly.

The accepted solution

1int solution(const vector<int>& nums) {
2 int result = 0;
3 for (int x : nums) {
4 result = result ^ x;
5 }
6 return result;
7}

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.