import collections class Solution(object): def hammingWeight(self,n): """ :param n:int :return: int """ k="{0:b}".format(n) m=collections.Counter(k) return m['1'] p=Solution() print p.hammingWeight(11)
python int to binary and count the number of 1
最新推荐文章于 2024-08-15 09:47:08 发布