codekofi
← All problems

Problem 2

Easy

1 · Worked examples

0 / 3

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.

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
3 unordered_set<int> seen;
4
5 for (int x : nums) {
6 if (seen.count(x)) {
7 return true;
8 }
9 seen.insert(x);
10 }
11
12 return false;
13}

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.