Tap here to switch tabs
Problem
Submissions

Problem: Hamming Distance

Hamming Distance compares two nonnegative integers bit by bit and asks you to return how many corresponding bit positions contain different values.

Statement

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

Given two integers x and y, your task is to find and return the Hamming distance between them.

Constraints:

  • 0≤0 \leq x, y ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Hamming Distance

Hamming Distance compares two nonnegative integers bit by bit and asks you to return how many corresponding bit positions contain different values.

Statement

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

Given two integers x and y, your task is to find and return the Hamming distance between them.

Constraints:

  • 0≤0 \leq x, y ≤231−1\leq 2^{31} - 1