未验证 提交 017d552d 编写于 作者: K KEQI HUANG 提交者: GitHub

Update 191._number_of_1_bits.md

上级 88bbfe82
......@@ -12,18 +12,14 @@ Easy
转成二进制,数1的个数
```
```python
class Solution(object):
def hammingWeight(self, n):
"""
:type n: int
:rtype: int
"""
count = 0
while n > 0:
count += n % 2
n = n//2
return count
return bin(n).count('1')
```
......@@ -54,7 +50,7 @@ AC代码
```
```python
class Solution(object):
def hammingWeight(self, n):
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册