清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
# -*- coding:utf-8 -*-
class Solution:
def NumberOf1(self, n):
if n>=0:
nbin = bin(n)
count = nbin.count('1')
return count
else:
num = abs(n)
nbin = bin(num-1)
count = 32-nbin.count('1')
return count