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 de87b63 commit e713338Copy full SHA for e713338
338-Counting-Bits.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ def countBits(self, n: int) -> List[int]:
3
+ dp = [0] * (n + 1)
4
+ offset = 1
5
+
6
+ for i in range(1, n + 1):
7
+ if offset * 2 == i:
8
+ offset = i
9
+ dp[i] = 1 + dp[i - offset]
10
+ return dp
0 commit comments