int bitCount[N];

bitCount[0] = 0;
for(int i = 1; i < N; ++i)
   bitCount[i] = bitCount[i>>1] + (i&1);

On Thursday, June 20, 2013 11:03:35 PM UTC-4, shubham saini wrote:
>
> How to count no of set bits for all numbers from 1 to n for a given n...
>
> i knew brute force any better solution ?? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Reply via email to