Single Number

In the array nums, every value appears exactly twice except one, which appears once. Return that one.

Constraints

  • 1 ≤ length of nums ≤ 20,001 (always odd)
  • -30,000 ≤ nums[i] ≤ 30,000

Example 1

Input
nums = [2,2,1]
Output
1
Why:

2 appears twice, 1 once.

Example 2

Input
nums = [4,1,2,1,2]
Output
4
Why:

1 and 2 come in pairs.

Hints

    Was this a good challenge?

    Solved by
    0
    Submissions
    0
    Accepted
    –