24: Count bits
Given a non-negative integer. Count the number of 1
for each number from 0
to given integer
(inclusive)
Example 1
Input: 3
Output: [0, 1, 1, 2]
Explanation:
0
=0
,1
=01
,2
=10
,3
=11
Example 2
Input: 7
Output: [0, 1, 1, 2, 1, 2, 2, 3 ]
Helpful article