Problem :

https://leetcode.com/problems/counting-bits/


My Solution :

class Solution:
    def countBits(selfnum):
        ans = [0]*(num+1)
        size = 1
        while True:
            for i in range(size):
                try:
                    ans[i+size] = ans[i]+1
                except:
                    return ans
            size *= 2
secret