Given an integer n, return an array answer where answer[i] is the number of 1 bits in the binary representation of i.
Examples
Input: n = 2 Output: [0,1,1]
Input: n = 5 Output: [0,1,1,2,1,2]
Constraints
- 0 <= n <= 100,000
Return the number of set bits for every number from 0 through n.
Given an integer n, return an array answer where answer[i] is the number of 1 bits in the binary representation of i.
Input: n = 2 Output: [0,1,1]
Input: n = 5 Output: [0,1,1,2,1,2]