#K10311. Find the Unique Element (Appears Once)
Find the Unique Element (Appears Once)
Find the Unique Element (Appears Once)
You are given a list of integers where every integer appears exactly three times except for one integer which appears exactly once. Your task is to find and output this unique integer.
Hint: Use bitwise operators to achieve a solution with optimal time and space complexity.
The solution must read the input from stdin
and write the result to stdout
. The input format is described below.
inputFormat
The first line of input contains an integer n representing the number of elements in the list. The second line contains n space-separated integers.
Example:
4 2 2 3 2
outputFormat
Output the unique integer that appears exactly once.
Example:
3## sample
4
2 2 3 2
3