Find the Unique Element Among Pairs
Problem statement
You are given a nonempty integer array nums. Exactly one value appears once and every other value appears exactly twice.
Return the value that appears once. The input is not necessarily sorted.
Function
singleNumber(nums: int[]) → intExamples
Example 1
nums = [4,1,2,1,2]return = 4The values 1 and 2 form pairs, leaving 4.
Example 2
nums = [-7,3,3]return = -7The two 3 values cancel as a pair.
Constraints
1 <= nums.length <= 200001.nums.lengthis odd.-1000000000 <= nums[i] <= 1000000000.- Exactly one value appears once; every other value appears twice.