The Hamming distance between two integers is the number of bit positions at which their binary representations differ. Given two integers x and y, return the Hamming distance between them.
The Hamming distance between two integers is the number of bit positions at which their binary representations differ. Given two integers x and y, return the Hamming distance between them.
Example 1:
Input: {"x":1,"y":4}
Output: 2
Constraints:
0≤x,y≤231−1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"x":1,"y":4}
Line up x = 1 and y = 4 bit by bit. The Hamming distance counts the columns where they disagree.