LeetCode
Counting Bits
Click
here
for an explanation.