Hamming Distance solution (C)


  • 0
    E
    int hammingDistance(int x, int y) {
        int d = 0;
        int xy = x ^ y;
        while (xy) {
            d += xy & 1;
            xy >>= 1;
        }
        return d;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.