Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def countBits(self, n: int) -> List[int]:
- bits = [0] * (n + 1)
- offset = 1
- for i in range(1, n + 1):
- if offset * 2 == i:
- offset *= 2
- bits[i] = bits[i - offset] + 1
- return bits
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement