Skip to content

Commit 083991d

Browse files
author
sangbeenmoon
committed
solved number-of-1-bits.
1 parent 7574a46 commit 083991d

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

number-of-1-bits/sangbeenmoon.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Solution:
2+
def hammingWeight(self, n: int) -> int:
3+
cnt = 0
4+
while n > 0:
5+
if n % 2 == 1:
6+
cnt = cnt + 1
7+
n = n // 2
8+
print(n)
9+
return cnt

0 commit comments

Comments
 (0)