#K40412. Find the Single Number
Find the Single Number
Find the Single Number
Given an array of integers in which every integer appears exactly twice except for one, your task is to find and output the unique integer that appears only once.
One efficient approach is to use the bitwise XOR operator. Recall that for any integer (a), we have (a \oplus a = 0) and (a \oplus 0 = a). Therefore, if you XOR all the numbers together, the duplicate numbers cancel out, leaving only the unique number.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n) representing the number of elements. The second line contains (n) space-separated integers.
outputFormat
Output a single integer — the number that appears only once, printed to standard output (stdout).## sample
5
4 1 2 1 2
4
</p>