Single Number
You're given a non-empty integer array nums where every element appears exactly **twice**, except for one element that appears exactly **once**. Find and return that single element.
Your solution should run in linear time and use only constant extra space (no hash map or counting structure).
Example cases
- single value in the middlein nums = [2,2,1]out 1
- single value at the startin nums = [4,1,2,1,2]out 41 and 2 each appear twice; 4 appears once.
- one-element arrayin nums = [1]out 1
Constraints
- 1 <= nums.length <= 3 * 10^4
- -3 * 10^4 <= nums[i] <= 3 * 10^4
- Every element appears exactly twice, except for one element which appears exactly once.
nums =
[2,2,1]