自己的解法
class Solution:
def countBits(self, n: int) -> List[int]:
left = -1
count = [0]
num_1 = 0
for i in range(1, n + 1):
temp = i
while left != 1 and left != 0:
left = temp // 2
right = temp % 2
if right != 0 and left != 0:
num_1 += 1
temp = left
num_1 += 1
count.append(num_1)
num_1 = 0
left = -1
return count