Every element in the array appears exactly twice, except for one element that appears once. Find that single element.
With nums = [2,2,1]:
- 2 appears twice, 1 appears once.
- Answer: 1.
With nums = [4,1,2,1,2]:
- 1 appears twice, 2 appears twice, 4 appears once.
- Answer: 4.
Must use O(1) extra space.
Constraints: 1≤ nums.length ≤3×104.