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 c62e032 commit cfb7db6Copy full SHA for cfb7db6
number-of-1-bits/yhkee0404.py
@@ -0,0 +1,4 @@
1
+class Solution:
2
+ @lru_cache
3
+ def hammingWeight(self, n: int) -> int:
4
+ return 1 + self.hammingWeight(n - (n & - n)) if n else 0
0 commit comments