Skip to content

Commit c36dd0c

Browse files
committed
number of 1 bits solution
1 parent 4edb975 commit c36dd0c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

number-of-1-bits/mrlee7.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+
result = 0
4+
5+
while n > 0:
6+
result += n % 2
7+
n //= 2
8+
return result
9+

0 commit comments

Comments
 (0)