Easy and Simple


  • 0
    A
    int hammingDistance(int x, int y) 
    {
    	int xor = x ^ y;
    	int iCount = 0;
    	while (xor) {
    		iCount += xor & 0x01;
    		xor = xor >> 1;
    	}
    	return iCount;
    }
    

Log in to reply
 

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