Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Single Number II

Medium
bit-manipulationarray

Every element appears exactly three times except one, which appears once. Find it in O(n) time and O(1) space.

Input: one line of space-separated integers. Output: the single number.

Example 1
Input:
2 2 3 2
Output:
3
Example 2
Input:
0 1 0 1 0 1 99
Output:
99

Constraints

  • 1 ≤ nums.length ≤ 3·10^4
  • -2^31 ≤ values ≤ 2^31 − 1
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.