The Number Without a Pair
You are given a list of integers nums. Every number in it appears exactly twice, except one number, which appears exactly once. Return that number.
The two copies of a pair can be anywhere in the list, not necessarily next to each other.
Examples
nums = [4, 1, 2, 1, 2] → 4
nums = [7] → 7
nums = [3, 9, 3] → 9In the first example 1 and 2 each appear twice, and 4 only once.
Constraints
- Between 1 and 19,999 numbers, each between -1,000,000,000 and 1,000,000,000.
- Exactly one number appears once; every other appears twice.
- Aim for O(n): look at each number a constant number of times.
Console
›Run to see what your code prints
Run checks the 3 visible cases here, in your browser. Submit runs all 7 on the judge, 4 of them hidden, and measures how your solution scales.
Expected is the reference solution's answer, from the judge. An input that breaks the statement's other rules may get any answer.