Description

The Hamming distance between two integers is the number of positions where corresponding bits differ.

Examples

Input:x = 1, y = 4
Output:2
Explanation:

0001 vs 0100 differ in 2 positions.

Input:x = 0, y = 15
Output:4
Explanation:

0000 vs 1111 differ in all 4 positions (bits 0, 1, 2, and 3).

Input:x = 7, y = 7
Output:0
Explanation:

0111 vs 0111 are identical, so no bits differ.

Constraints

  • 0 ≤ x, y ≤ 2³¹ - 1

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!