这题太简单了,我用了位运算
int hammingDistance(int x, int y) {
int count = 0;
while(x!=0||y!=0){
if ((x&0x1) != (y&0x1)) count++;
x = x>>1;
y = y>>1;
}
return count;
}
这题太简单了,我用了位运算
int hammingDistance(int x, int y) {
int count = 0;
while(x!=0||y!=0){
if ((x&0x1) != (y&0x1)) count++;
x = x>>1;
y = y>>1;
}
return count;
}