#K53197. Single Number
Single Number
Single Number
You are given an array of integers where every element appears exactly three times except for one element which appears exactly once. Your task is to identify that unique element.
Your solution must run in linear time \(O(n)\) and use constant extra space.
Example 1:
Input: [2, 2, 3, 2]
Output: 3
Example 2:
Input: [0, 1, 0, 1, 0, 1, 99]
Output: 99
inputFormat
The input is given via standard input (stdin) in the following format:
- An integer \(n\) representing the number of elements in the array.
- A line containing \(n\) space-separated integers.
For example:
4 2 2 3 2
outputFormat
Output a single integer to standard output (stdout), which is the unique element that appears exactly once.
For example:
3## sample
4
2 2 3 2
3