class Solution { public: int hammingDistance(int x, int y) { int r = x ^ y; return bitCount(r); } int bitCount(int x) { int res = 0; while (x) { x -= x & (-x); res++; } return res; } };
class Solution { public: int hammingDistance(int x, int y) { int r = x ^ y; return bitCount(r); } int bitCount(int x) { int res = 0; while (x) { x -= x & (-x); res++; } return res; } };