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 480b937 commit ecb817aCopy full SHA for ecb817a
number-of-1-bits/dm.py
@@ -0,0 +1,6 @@
1
+class Solution:
2
+ def hammingWeight(self, n: int, acc: int = 0) -> int:
3
+ if n == 0:
4
+ return acc
5
+
6
+ return self.hammingWeight(n // 2, acc + n % 2)
0 commit comments