标签:odi turn scribe python item utf-8 输入 一个 整数
# -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): # write code here return sum([(n>>i & 1) for i in range(0,32)])
方法2:
# -*- coding:utf-8 -*- class Solution: def NumberOf1(self, n): # write code here count = 0 while n: count += 1 n = (n-1) & n return count
标签:odi turn scribe python item utf-8 输入 一个 整数
原文地址:https://www.cnblogs.com/tianqizhi/p/9614106.html