作者:hojk | 来源:互联网 | 2023-08-20 19:38
classSolution{public:inthammingDistance(intx,inty){异或:找到哪几位不一样inttempx^y;intres0;统
class Solution {
public:int hammingDistance(int x, int y) {int temp = x^y;int res = 0;while (temp > 0){res += temp % 2;temp /= 2;}return res;}
};