LeetCode 136 Single Number - Problem Statement

The problem

Every element in the array appears exactly twice, except for one element that appears once. Find that single element.

With nums = [2,2,1]:

  • 2 appears twice, 1 appears once.
  • Answer: 11.

With nums = [4,1,2,1,2]:

  • 1 appears twice, 2 appears twice, 4 appears once.
  • Answer: 44.

Must use O(1)O(1) extra space.

Constraints: 11 \le nums.length 3×104\le 3 \times 10^4.