位运算:
Mycode
class Solution {
public:
/**
* 获得两个整形二进制表达位数不同的数量
*
* @param m 整数m
* @param n 整数n
* @return 整型
*/
int countBitDiff(int m, int n) {
int ans=m^n;
int cnt=0;
while(ans){
ans=ans&(ans-1);
cnt++;
/*if(ans%2==1)
cnt++;
ans/=2;*/
}
return cnt;
}
};