LC 136
LeetCode 136 · Easy

Single Number

Every element appears twice except one; find it.


Try it

Step through the core mechanic. The simulator below runs the bit manipulation shape this problem is built on.

Walk the pattern

No dedicated step-through for this one yet. The shape is Bit manipulation — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.

The approach

XOR everything together. Pairs cancel (x ^ x = 0) and 0 ^ y = y, leaving the unique value. O(1) space, no hashing.

AspectValue
PatternBit manipulation
Recognise it byOne element appears once, all others twice.
Time complexityO(n)
Space complexityO(1)
DifficultyEasy

Who asks it

Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.