Easy15 pts
Single Number (XOR)
Given a non-empty array where every element appears twice except for one, find that single element. Use XOR: a ^ a = 0, a ^ 0 = a. XOR all numbers together. Example: [4,1,2,1,2] → 4 (1^1=0, 2^2=0, 4^0=4)
Input
Line 1: n. Line 2: n space-separated integers.
Output
The single number.
Sample
5 4 1 2 1 2
Expected
4
Loading editor…
Output
No output yet. Run your code to see results.