Return a list of length n + 1 where entry i is the number of set bits in i, for i = 0, 1, ..., n.
For n = 5 the answer is [0, 1, 1, 2, 1, 2].
Example 1
Input:
count_bits_up_to(5)
Output:
[0, 1, 1, 2, 1, 2]
Example 2
Input:
count_bits_up_to(0)
Output:
[0]
0 <= n <= 200000No results yet
Run your code to check it against the examples, or submit to run every test.