Solution by gangpao


  • 0
    W

    #include<stdio.h>
    int main(){
    // int hammingDistance(int x, int y)
    // {
    int x,y;
    int dis=0;
    int z;
    scanf("%d,%d",&x,&y);
    z=x^y;

    while(z)
    {
        if((z>>1)<<1 != z)
        {
            ++dis;
        }
        
        z>>=1;
    }
    printf("%d",dis) ;
    

    // }
    }


Log in to reply
 

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