#K44767. Find the Odd Occurrence
Find the Odd Occurrence
Find the Odd Occurrence
You are given a list of integers where every integer appears an even number of times except for exactly one integer which appears an odd number of times. Your task is to find and output that integer.
In other words, if the list is \(A = [a_1, a_2, \dots, a_n]\), there exists a single integer \(x\) such that the number of occurrences of \(x\) in \(A\) is odd, and all other integers appear an even number of times.
You can solve this problem efficiently by utilizing the XOR operation. Recall that for any integer \(a\), \(a \oplus a = 0\) and \(a \oplus 0 = a\). By applying XOR to all the numbers in the array, the result will be the number that appears an odd number of times.
inputFormat
The input consists of two lines:
- The first line contains a single integer \(n\) representing the number of elements in the list.
- The second line contains \(n\) space-separated integers.
outputFormat
Output a single integer, which is the number that appears an odd number of times in the list.
## sample9
20 1 1 2 2 3 3 20 20
20