#137

Single Number II

specialist · 610 · lc medium +29 · verified · 66.8% accepted · 8,639 likes · top 72%

play →

Description

You are given an integer array nums where every element appears exactly three times except for one element which appears exactly once.

Find and return that unique element.

Your solution must run in linear time and use only constant extra space.

Example 1:

Input: nums = [2,2,3,2]
Output: 3

Example 2:

Input: nums = [0,1,0,1,0,1,99]
Output: 99

Code

1
2
3