leetle

35. Counting Bits

82%

Write a function solve that returns an array of the number of 1-bits (Hamming weight) for each number from 0 to n.

Example: Input: 2 Output: [0,1,1]

Make sure you return your solution, don't print!

Python3

def solve(n):
    pass