AlgoScope

XOR Pairing (Single Number)

AlgorithmintermediateBit Manipulation

XOR everything; duplicates cancel and the unpaired value remains.

Decision · step 2 of 7XOR Tricks: Find the single number
4011221324i

0 xor 4 = 4. First time 4 appears, so its bits are folded in.

Open in the player →or start at step 2

What you will see

A running XOR row; each duplicate pair zeroes itself out.

How xor tricks works →

Cost

BestO(n)
AverageO(n)
WorstO(n)
SpaceO(1)

How you work with it here

play it through, step one change at a time, run it on your own input, try operations in any order.

Screen readers: Each bit announces its position and value; each step announces the operation and the resulting number in binary and decimal.

Reduced motion: Bits flip with a crossfade; masks appear in place.

Before this

Taught by the same lesson

XOR Tricks covers these too, in the same run.