leetcode-python-汉明距离
时间:2021-06-11 19:07:12
收藏:0
阅读:0
1)取异或,然后计算1的个数
class Solution: def hammingDistance(self, x: int, y: int) -> int: t = x^y count = 0 while t: count += 1 t = t& t-1 return count
评论(0)