Counting Bits
easyReturn array where ans[i] is the number of 1s in binary of i
Counting Bits
Key Insight
bits[i] = bits[i >> 1] + (i & 1). Use previously computed values.
Step 1Base Case
0
0
=0
0
0
0
0
0
0
0
76543210
bits[0] = 0
bits[0] = 0 (no 1-bits in 0)
1 / 5