Example 1
Input
nums = [2, 2, 1]
Output
1
Loading CodeSprint...
/problems/single-number
Every value in the list appears exactly twice except one value that appears once. Return the value without a matching pair.
Implement this function and return the result. CodeSprint supplies each test case automatically.
singleNumber(nums) → numberInput
nums = [2, 2, 1]
Output
1
Input
nums = [4, 1, 2, 1, 2]
Output
4
Constraints
1 <= nums.length <= 100,000 Every value except one occurs exactly twice.