韩明距离就是两个二进制数相应位置不同的个数
class Solution {
public int hammingDistance(int x, int y) {
int i = x ^ y;
int count=0;
while (i != 0) {
++ count;
i = (i-1)& i;
}
return count;
}
}
韩明距离就是两个二进制数相应位置不同的个数
class Solution {
public int hammingDistance(int x, int y) {
int i = x ^ y;
int count=0;
while (i != 0) {
++ count;
i = (i-1)& i;
}
return count;
}
}