Easy
Return the bit count for every number from 0 to n.
Given a non-negative integer n, return an array where answer[i] is the number of set bits in i for every 0 <= i <= n.
Examples
Input: n = 5
Output: [0,1,1,2,1,2]
Constraints
- 0 <= n
Coding Challenge
Return the bit count for every number from 0 to n.
Given a non-negative integer n, return an array where answer[i] is the number of set bits in i for every 0 <= i <= n.
Input: n = 5
Output: [0,1,1,2,1,2]
Preparing your coding workspace...