![](https://img.haomeiwen.com/i13792534/1da0ec97503f76b3.jpg)
class Solution:
def NumberOf1(self, n):
# write code here
n = n & 0xFFFFFFFF
count = 0
for i in range(32):
tmp = n >> i
if tmp & 1 != 0:
count += 1
return count
class Solution:
def NumberOf1(self, n):
# write code here
n = n & 0xFFFFFFFF
count = 0
for i in range(32):
tmp = n >> i
if tmp & 1 != 0:
count += 1
return count
本文标题:二进制中1的个数
本文链接:https://www.haomeiwen.com/subject/qigznctx.html
网友评论