FunctionRacerProblemsRace

Hamming Distance

EasyBitsPython, JavaScript, TypeScript, Java, C++

Write x and y in binary. Return the number of bit positions at which the two numbers have different bits.

Example 1

x 1
y 4
returns 2

001 and 100 differ in two places.

Example 2

x 3
y 1
returns 1

11 and 01 differ once.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems