Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Problem Statement

For a given positive integer, n, your task is to return an array of length n+1 such that for each x where 0 ≤ x ≤ n , result[x] is the count of 1s in the binary representation of x.

Constraints:

0 ≤ n ≤ 104

Example

    Input: n = 3            
    Output = [0,1,1,2]
        x->0: 0  (no ones)
        x->1: 1  (1 one)
        x->2: 10 (1 one)
        x->3: 11 (2 ones)