313. Set Bits for 0..N
EasyBitsDP
Print the number of set bits of every integer from 0 to n.
Input format
A single integer n.
Output format
n + 1 counts.
Example 1
Input
2
Output
0 1 1
Example 2
Input
5
Output
0 1 1 2 1 2
Constraints
0 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…