Hamming Distance
Write x and y in binary. Return the number of bit positions at which the two numbers have different bits.
Example 1
x 1
y 4
returns 2
001 and 100 differ in two places.
Example 2
x 3
y 1
returns 1
11 and 01 differ once.
Constraints
0 <= x, y <= 2**31 - 1
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.