Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Hsinha11/Leetcode-solutions
/ countBits
Method
countBits
338-counting-bits/counting-bits.py:6–10 ·
view source on GitHub ↗
(self, n: int)
Source
from the content-addressed store, hash-verified
4
5
class
Solution:
6
def
countBits(self, n: int) -> List[int]:
7
dp = [0] * (n + 1)
8
for
i in range(1, n + 1):
9
dp[i] = dp[i >> 1] + (i & 1)
10
return
dp
Callers
nothing calls this directly
Calls
no outgoing calls
Tested by
no test coverage detected