3 ms c/c++ solution


  • 0
    Y

    '''
    int hammingDistance(int x, int y) {
    /** xor x and y */
    int z= x^y;

    int distance =0;
    while (z!=0){
        if(z&1==1){
            distance +=1;
        }
        z=z>>1;
    }
    
    return distance;
    

    }
    '''


Log in to reply
 

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