Quant Memo
Coding/●●●●●

Hamming distance between two integers

The Hamming distance between two integers is the number of bit positions where they differ.

a = 1  (0001)
b = 4  (0100)
-> 2      # they differ in two positions

Return the Hamming distance of a and b in time proportional to the number of differing bits, not the full word width.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions