codekofi
← All problems

Problem 2

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

1bool solution(const vector<int>& nums) {
2 unordered_set<int> seen;
3 for (int x : nums) {
4 if (seen.count(x)) return true;
5 seen.insert(x);
6 }
7 return false;
8}

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.