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+=1
return count
461. Hamming Distance(快速算法)
最新推荐文章于 2019-08-31 10:29:22 发布