Single Number II

Medium · Bit Manipulation · about 20 minutes

Asked at Google, Amazon, Microsoft, Bloomberg, Jane Street.

Every value in nums occurs three times, except for one value that occurs only once. Return that value, in O(n) time and O(1) extra memory.