Hamming Distance Problem

Hamming Distance Problem — ExecCode Easy DSA Practice

Solve the Hamming Distance problem on ExecCode. Free online easy DSA practice in Bit Manipulation. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given two integers x and y, return the Hamming distance between them. Your task is to the Hamming distance between two integers is the number of positions at which the corresponding bits are different. Return the required answer exactly as shown in the examples.

Examples

Input {"x": 1, "y": 4}; Output 2. Input {"x": 3, "y": 1}; Output 1

Constraints

0 <= x, y <= 2^31 - 1

Practice Hamming Distance free on ExecCode. Browse DSA problems, topic map, and placement guides.