#K32877. Single Occurrence Element
Single Occurrence Element
Single Occurrence Element
Given an array of integers in which every element appears twice except for one element that appears only once, your task is to find and output that unique element.
The solution should be efficient, with a linear runtime complexity and constant extra space.
Hint: You can use the (\texttt{XOR}) operation since (a \oplus a = 0) and (a \oplus 0 = a), making it ideal for this problem.
inputFormat
The input is provided via standard input (stdin) in the following format:
- The first line contains a single integer (n), representing the number of elements in the array.
- The second line contains (n) space-separated integers.
outputFormat
Output the unique element (the one that occurs only once) to standard output (stdout).## sample
7
4 3 2 4 1 3 2
1