424. Henry's Binary Revolution
King Henry VIII desires to break away from the catholic church and revolutionize the decimal system. He seeks to implement the binary number system and tasks you with determining the count of 1s in the binary representation of each number up to a given number N. Your objective is to create an array ans of length n + 1, where ans[i] represents the number of 1s in the binary form of i (0 <= i <= n). Can you accomplish this in linear time O(n) and without utilizing any built-in functions?
The first line contains an integer N, indicating the size of the array.
Print an array ans, where each ans[i] represents the number of 1s in the binary representation of i.
0 1 1 2 1 2
0 <= n <= 10^5