Easy · Math
Hamming distance
Given two non-negative integers x and y, return their Hamming distance: the number of bit positions at which the binary representations of x and y differ.
Examples
Example 1
x=1, y=4Output: distance = 2
Example 2
x=3, y=1Output: distance = 1
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.