You get an array of integers in which every number occurs exactly twice, except one that occurs once. Find that one, in one pass and with O(1) extra memory. Our example: [10, 3, 7, 3, 10] — the answer is 7.
input
nums: an array of integers in which every number comes twice, except one that comes once.
returns
The number that comes once.
constraints
1 ≤ nums.length ≤ 3001
−3·10⁴ ≤ nums[i] ≤ 3·10⁴
every number comes exactly twice, except one that comes once
our 13 tests keep to them
examples
Open a test in the tests panel: it shows the input and the expected answer.