We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6d1ee5a commit a2d1621Copy full SHA for a2d1621
number-of-1-bits/hajunyoo.py
@@ -0,0 +1,9 @@
1
+class Solution:
2
+ def hammingWeight(self, n: int) -> int:
3
+ n = int(n)
4
+ cnt = 0
5
+ while n > 0:
6
+ if n % 2 == 1:
7
+ cnt += 1
8
+ n = n // 2
9
+ return cnt
0 commit comments