Leetcode 477. Total Hamming Distance
按位计算就行.
class Solution(object): def totalHammingDistance(self, nums): size, ans = len(nums), 0 while True: zero= 0 count=[0,0] for i in range(size): if nums[i] == 0: zero += 1 count[nums[i] % 2] += 1 nums[i] >>= 1 ans += count[0] * count[1] if zero == size: return ans