You get an array of integers in which every number occurs three times, except one that occurs once. Find that one in linear time and with O(1) extra memory. Our example: [3, 5, 3, 6, 5, 3, 5] — the answer is 6.
input
nums: an array of integers in which every number comes three times, except one that comes once.
returns
The number that comes once. It may be negative: a 32-bit answer built bit by bit has its sign in bit 31.
constraints
1 ≤ nums.length ≤ 3001
−2³¹ ≤ nums[i] ≤ 2³¹ − 1
every number comes exactly three times, except one that comes once
our 14 tests keep to them
examples
Open a test in the tests panel: it shows the input and the expected answer.