Single Number (XOR)

Easy · Bit Manipulation · about 10 minutes

Asked at Amazon, Google, Apple.

Every element of the non-empty array nums appears twice except for one, which appears once. Find it in O(n) time and O(1) extra space.