Skip to content

Instantly share code, notes, and snippets.

Created September 22, 2017 18:13
public class Solution {
public int hammingDistance(int x, int y) {
int count = 0;
while (x > 0 || y > 0) {
count += (x & 1) ^ (y & 1);
x >>>= 1;
y >>>= 1;
}
return count;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment