class Solution {
public int hammingDistance(int x, int y) {
// 异或
int n = x ^ y;
int count = 0;
while (n != 0) {
count++;
n = n & (n - 1);
}
return count;
}
}
10-12
326
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)