For each number, count its bits individually using Brian Kernighan's trick.
Each count takes where is the number of set bits. Summed over numbers, that's in the worst case.
Can you compute each count in using previous results?
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
The trap
For each number, count its bits individually using Brian Kernighan's trick.
Each count takes where is the number of set bits. Summed over numbers, that's in the worst case.
Can you compute each count in using previous results?