#C4987. Find the Unique Number
Find the Unique Number
Find the Unique Number
In this problem, you are given a list of integers of size (n) where every element appears exactly twice except for one element which appears only once. Your task is to find and output this unique number. The solution leverages the bitwise XOR operation, based on the properties (a \oplus a = 0) and (a \oplus 0 = a), so that duplicate numbers cancel each other out, leaving the unique number.
inputFormat
The first line of input contains an integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers.
outputFormat
Output a single integer which is the unique number that appears exactly once in the array.## sample
5
4 1 2 1 2
4