#C11260. Find the Hidden Number
Find the Hidden Number
Find the Hidden Number
You are given an array of N integers in which every element appears exactly twice except for one element which appears only once. Your task is to identify this unique element. The solution involves utilizing the bitwise XOR operator. Recall that for any integer \(a\), we have \(a \oplus a = 0\) and \(a \oplus 0 = a\). Using these properties, the XOR of all numbers in the array will yield the hidden number.
inputFormat
The input begins with an integer T representing the number of test cases. For each test case, the first line contains an integer N denoting the number of elements in the array. The second line contains N space-separated integers.
Input Format:
\(T\)
For each test case:\(\quad N\)
\(\quad a_1\ a_2\ \dots\ a_N\)
outputFormat
For each test case, output a single line containing the hidden number which appears only once in the array.
Output Format:
For each test case, print the result on a new line.
3
5
1 2 3 2 1
7
4 5 4 5 6 7 7
1
99
3
6
99
</p>