461. Hamming Distance
Practice Hamming Distance for free on NudgeCode: Easy, Bit Manipulation pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
The Hamming distance of two integers is the number of bit positions at which their binary forms differ. Return the Hamming distance of the non-negative integers x and y.
Example
x = 1, y = 4 -> 2 (001 vs 100)
x = 3, y = 1 -> 1 (11 vs 01)
Constraints
- 0 <= x, y <= 2^31 - 1