The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
class Solution(object):
def hammingDistance(self, x, y):
"""
:type x: int
:type y: int
:rtype: int
"""
result=x^y
count=0
while(result):
result=result&(result-1)
count=count+1
return count
使用异或获取hamming distance,再获取的1的个数,将n&(n-1)或取从右到左的第一个1