#K45537. Find the Unique Number in an Array
Find the Unique Number in an Array
Find the Unique Number in an Array
Given an array of integers where every integer appears exactly three times except one, find and output the unique integer that appears only once.
The solution should run in O(n) time complexity and use constant extra space.
Mathematically, if we denote the unique number as \( x \) and the repeated numbers as \( a_i \) (each appearing three times), then the problem can be viewed through bitwise manipulation: \[ \text{ones}, \text{twos} = 0, 0 \] A proper understanding and utilization of bitwise operations is key to solving this problem efficiently.
inputFormat
The first line of input contains an integer \( n \) which is the number of elements in the array.
The second line contains \( n \) space-separated integers. It is guaranteed that every integer appears three times except for one which appears exactly once.
outputFormat
Output the integer that appears only once.
## sample4
2 2 3 2
3