Hamming Distance
easyCount differing bit positions between two numbers
Hamming Distance
Key Insight
XOR gives 1s where bits differ. Count the 1s in the XOR result.
Step 1Problem
1
1
=0
0
0
0
0
0
0
1
4
4
=0
0
0
0
0
1
0
0
76543210
001 vs 100
Hamming distance between 1 and 4.
1 / 5