Skip to content

Commit 10d6a8f

Browse files
committed
number of 1 bits solution
1 parent 432fda4 commit 10d6a8f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

number-of-1-bits/devyejin.py

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

0 commit comments

Comments
 (0)