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.
2 parents dcd640a + 2daa9b6 commit 8a309dcCopy full SHA for 8a309dc
Number of 1 Bits.py
@@ -0,0 +1,7 @@
1
+class Solution:
2
+ def hammingWeight(self, n):
3
+ count = 0
4
+ while n:
5
+ count += 1
6
+ n = (n - 1) & n
7
+ return count
0 commit comments