Every value in nums appears exactly three times except for one value that appears exactly once. Return the value that appears once.
Input / output
nums: int[]Examples
nums = [2, 2, 3, 2] returns 3.nums = [0, 1, 0, 1, 0, 1, 99] returns 99.nums = [1, 1, 1, 2] returns 2.Constraints
1 <= nums.length <= 30000-2^31 <= nums[i] <= 2^31 - 1Edge cases
0.Target complexity
O(n) time and O(1) extra space.Hints
1 when its count is taken modulo 3.Follow-up
Can you generalize the bit-counting trick for "every element appears k times except one"?