开启leetcode刷题模式
今天只做了最简单的 Hamming distance
class Solution(object):
def hammingDistance(self, x, y):
"""
:type x: int
:type y: int
:rtype: int
result = bin(x^y).replace('0b','')
result = str(result)
count=0
for c in result:
if c == '1':
count+=1
return count
"""
return bin(x^y).count('1')