#K84842. Find the Single Number
Find the Single Number
Find the Single Number
You are given an array of integers where every element appears exactly twice except for one element which appears only once. Your task is to find and output the number that appears only once.
Input Format: The first line contains an integer n denoting the number of elements in the array. The second line contains n space-separated integers.
Output Format: Output a single integer which is the number that appears only once.
Hint: Use bitwise XOR operation. Recall that for any integer a,
\(a \oplus a = 0\) and
\(a \oplus 0 = a\). This guarantees that all paired elements cancel out, leaving the unique element.
inputFormat
The first line contains an integer n (1 ≤ n ≤ 105), representing the number of elements in the array. The second line contains n space-separated integers. It is guaranteed that exactly one element appears once and all others appear exactly twice.
outputFormat
Output a single integer which is the only number that appears once in the array.
## sample7
4 1 2 1 2 4 3
3
</p>