7. The Lonely Number
easybit manipulationarray
Every element of nums appears exactly twice, except for one element that appears once. Find that element.
Try to use O(1) extra space.
Example 1
Inputnums = [2,2,1]
Output1
Example 2
Inputnums = [4,1,2,1,2]
Output4
Example 3
Inputnums = [1]
Output1
Constraints
- 1 ≤ nums.length ≤ 3·10⁴ (odd)
- -3·10⁴ ≤ nums[i] ≤ 3·10⁴
Hint 1
`x ^ x = 0` and `x ^ 0 = x`.