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 4 outputs correctly.
| 1 | vector<int> solution(const vector<int>& nums, int target) { |
| 2 | int n = nums.size(); |
| 3 | unordered_map<int, int> seen; |
| 4 | for (int i = 0; i < n; i++) { |
| 5 | int need = target - nums[i]; |
| 6 | if (seen.count(need)) return {seen[need], i}; |
| 7 | seen[nums[i]] = i; |
| 8 | } |
| 9 | return {}; |
| 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.