Single Number
EasyBit Manipulation & Math
Decode it first. Clues, constraints, pattern and plan before any code.Every value in nums appears exactly twice, except one value that appears once. Return that value, using O(1) extra space.
nums = [2, 2, 1] → 1
nums = [4, 1, 2, 1, 2] → 4
nums = [-1, -1, -2] → -2Constraints
1 <= nums.length <= 3 * 10^4-3 * 10^4 <= nums[i] <= 3 * 10^4- Every element appears twice except for one, which appears once.