C++ | Leetcode C++题解之第461题汉明距离
题目:
题解:
class Solution {
public:int hammingDistance(int x, int y) {int s = x ^ y, ret = 0;while (s) {s &= s - 1;ret++;}return ret;}
};
题目:
题解:
class Solution {
public:int hammingDistance(int x, int y) {int s = x ^ y, ret = 0;while (s) {s &= s - 1;ret++;}return ret;}
};