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 d4394bd commit 7866201Copy full SHA for 7866201
number-of-1-bits/WHYjun.py
@@ -0,0 +1,7 @@
1
+class Solution:
2
+ def hammingWeight(self, n: int) -> int:
3
+ result = 0
4
+ for i in range(32):
5
+ if (n >> i) & 1:
6
+ result += 1
7
+ return result
0 commit comments