Single Number II

medium

Find element appearing once when others appear 3 times

Single Number II

Key Insight

Count bits at each position mod 3. Remaining bits form the single number.

Step 1Problem
No binary data

[2,2,3,2] - find element appearing once (others appear 3x).

1 / 5

Learn the Pattern

Practice the Code

Step-by-Step Walkthrough: Single Number II

Count bits at each position mod 3. Remaining bits form the single number.

  1. Problem

    [2,2,3,2] - find element appearing once (others appear 3x).

  2. Count Bit 0

    2=10, 3=11. Bit 0: 0+0+1+0=1. 1%3=1.

  3. Count Bit 1

    Bit 1: 1+1+1+1=4. 4%3=1.

  4. Build Result

    Bit 0=1, Bit 1=1 → binary 11 = 3

  5. Result

    The single number is 3!