cheetcode

146. Counting BitsEasy

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.

Examples

Input: n = 2
Output: [0,1,1]
Input: n = 5
Output: [0,1,1,2,1,2]

Constraints

  • 0 <= n <= 100,000