Hamming Distance

Easy
Math Bit Manipulation

Given two integers x and y, return the Hamming distance (number of differing bits).

Constraints

0 ≤ x, y ≤ 2^31 - 1

Examples

Example 1:
Input: 1 4
Output: 2
Explanation: 1=001, 4=100, differ in 2 positions
Example 2:
Input: 3 1
Output: 1
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.