#C8651. Find the Number with Odd Frequency
Find the Number with Odd Frequency
Find the Number with Odd Frequency
You are given a list of integers. Exactly one integer appears an odd number of times, while all the others appear an even number of times. Your task is to find and output that integer.
The input will be provided via standard input (stdin), where the first line contains an integer n specifying the number of elements in the array, and the second line contains n space-separated integers. The result should be printed to the standard output (stdout).
Note: It is guaranteed that there is only one integer that appears an odd number of times.
Mathematical Formulation:
Let \(A = [a_1,a_2,\dots,a_n]\) be the given sequence. Find the unique \(x\) such that \[ \#\{i : a_i=x\} \equiv 1 \pmod{2} \]
inputFormat
The first line contains a single integer n, the number of elements in the array. The second line contains n space-separated integers representing the elements of the array.
Example:
7 1 2 3 2 3 1 3
outputFormat
Output a single integer which is the number that appears an odd number of times in the array.
Example:
3## sample
7
1 2 3 2 3 1 3
3