Skip to content

Commit cfb7db6

Browse files
authored
number of 1 bits solution
1 parent c62e032 commit cfb7db6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

number-of-1-bits/yhkee0404.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)