Leetcode 461 Solution
This article provides solution to leetcode question 461 (hamming-distance)
Access this page by simply typing in "lcs 461" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/hamming-distance
Solution
class Solution {
public:
int hammingDistance(int x, int y) {
int z = x ^ y;
int cnt = 0;
while (z)
{
z = z & (z - 1);
cnt++;
}
return cnt;
}
};