汉明距离是两个字符串对应位置的不同字符的个数,这个题目没有说清楚,我在评论区看到的orz,好啦,上代码
class Solution {
public:
int hammingDistance(int x, int y)
{
int count=0;
if(x==y)
return 0;
while(x!=0||y!=0)
{
if(x%2!=y%2)
count++;
x=x/2;
y=y/2;
}
return count;
}
};