easyBit ManipulationFacebookAmazon
Lone Rune Finder
A monk sorts magical runes that always come in matching pairs — except one rogue rune. Find it.
Given a non-empty integer array where every element appears twice except one, return that single number.
Choose approach
4
0i
1
12
21
32
4Mapstate
x→4
bin→00000100
1/6
Narrationstep 1 of 6
XOR with 4 → x = 4 (bin 00000100).
Variables
i=0
x=4
bin=00000100
How to think about it
- XOR is commutative + associative.
- Loner survives because pairs annihilate.
Edge cases to catch in interview
- Single element -> itself.
- Negative numbers OK.
Examples
Example 1
1{"values":[2,2,1]}
Try your own input
SpacePlay / pause
← / →Previous / next step
RReset to start
. or >Cycle speed