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.
Locked until you have predicted 3 outputs correctly.
| 1 | bool 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.