//先标记不同的bit //然后数这个flag里有多少个1 int countBitDiff(int m, int n ) { // write code here int flag = m ^ n; int i = 0; int mask; int count = 0; while(i <= 31) { mask = 1 << i++; if (flag & mask) count++; } return count; }
//先标记不同的bit //然后数这个flag里有多少个1 int countBitDiff(int m, int n ) { // write code here int flag = m ^ n; int i = 0; int mask; int count = 0; while(i <= 31) { mask = 1 << i++; if (flag & mask) count++; } return count; }