Question
Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.
Bit Manipulation
If XOR operation is the addition in binary system, which can solve Single Number
, we can use addition in ternary system to solve this problem.
H and L represents the higher and the lower bit of a ternary number.
- Time Complexity: O(n)
- Space Complexity: O(1)