MEDIUMasked at 3 companies

Single Number II

A medium-tier problem at 65% community acceptance, tagged with Array, Bit Manipulation. Reported in interviews at Accenture and 2 others.

Founder's read

Single Number II hits your assessment and you blank on bit manipulation. You've got an array where every number appears three times except one that appears once, and you need to find it. Accenture, Yahoo, and Google have all asked this. The naive approach (hash map) works but fails the follow-up: solve it in O(1) space without touching the input. That's when the bit trick separates passers from fails. StealthCoder surfaces the solution in seconds if you hit this live and the pattern doesn't click.

Companies asking
3
Difficulty
MEDIUM
Acceptance
65%

Companies that ask "Single Number II"

If this hits your live OA

Single Number II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The trick is to track which bits appear in multiples of three across all numbers. For each bit position, count how many numbers have that bit set. If the count mod 3 leaves a remainder, that bit belongs to the single number. Most candidates get stuck trying to build a hash map or sorting the array, which wastes space or time. The real insight is that bit manipulation lets you build the answer bit by bit without extra data structures. Common pitfall: overthinking the bit counting logic or not realizing you need to track all 32 bits independently. If you blank on this in the assessment, StealthCoder runs invisibly and gives you the working code so you move to the next problem.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Single Number II recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Single Number II interview FAQ

Is the O(1) space constraint always enforced, or is O(n) hash map acceptable?+

The problem statement doesn't explicitly ban a hash map, but every mention from Google, Accenture, and Yahoo includes a follow-up asking for O(1) space. Count on the interviewer asking for it. The bit manipulation approach is the real answer they're testing.

What's the difference between this and Single Number I?+

Single Number I uses XOR (every number appears twice except one). This problem all numbers appear three times. XOR no longer works because XOR of three identical numbers gives the number itself, not zero. You need bit-by-bit counting modulo 3 instead.

How do I even start the bit manipulation approach?+

Iterate through all 32 bit positions. For each position, count how many numbers have that bit set. If count mod 3 is nonzero, that bit is part of the answer. Build the result by setting bits where count mod 3 equals 1.

Why is this medium and not easy if it's just iteration?+

The 52% acceptance rate reflects that the bit insight isn't obvious. Most candidates either timeout with brute force, fail the space constraint, or misunderstand bit manipulation. The jump from hash map to constant space is where difficulty lives.

Do I need to handle negative numbers or edge cases?+

The input can include negative numbers, and you're usually working with 32-bit signed integers. Edge case: single number is negative. The bit counting approach handles this correctly if you iterate through all 32 bits and interpret the result as a signed integer at the end.

Want the actual problem statement? View "Single Number II" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.