Hamming distance c++


  • 0
    T

    '''
    class Solution {
    public:
    int hammingDistance(int x, int y) {
    int result = 0;
    while(x != 0 || y != 0) {
    result += (1 & x) ^ (1 & y);
    x>>=1;
    y>>=1;
    }
    return result;
    }
    };
    '''


Log in to reply
 

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