cheetcode

144. Single NumberEasy

Find the element that appears exactly once when every other element appears twice.

You are given a non-empty array of integers where every element appears twice except for one.

Return the single element that appears only once.

Examples

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

Constraints

  • 1 <= nums.length <= 30,000
  • -30,000 <= nums[i] <= 30,000
  • Exactly one element appears once.