dsa · easy
Single Number
ArrayBit Manipulation
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space.
Arguments
nums— the input array of integers
**Example 1:** `` Input: nums = [2,2,1] Output: 1 ``
Constraints
1 <= nums.length <= 3 * 10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [2,2,1] Expected: 1
Example 2
Input: [4,1,2,1,2] Expected: 4