LeetCode 461. 汉明距离
class Solution {
public:
int hammingDistance(int x, int y) {
int cnt=0;
int t=x^y;
while(t)
{
cnt+=(t&1);
t>>=1;
}
return cnt;
}
};
有帮助的话可以点个赞,我会很开心的~