#K75027. Find the Odd Occurrence
Find the Odd Occurrence
Find the Odd Occurrence
Given a list of positive integers, exactly one integer appears an odd number of times while all the others appear an even number of times. Your task is to determine the number that appears an odd number of times.
This problem can be efficiently solved using the XOR operation, where we utilize the properties: \(a \oplus a = 0\) and \(a \oplus 0 = a\). By executing XOR on all numbers in the list, the even-occurring numbers cancel out, leaving the unique number that appears an odd number of times.
inputFormat
The input is given via standard input (stdin) and 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 positive integers.
outputFormat
Output a single integer to standard output (stdout): the number that appears an odd number of times.
## sample9
4 3 4 4 4 5 5 5 3
5