Create a count array to store count of numbers that have a particular bit set . count [ i ] stores count of array elements with i - th bit set .
INT_SIZE = 8 * sys . getsizeof ( int ) NEW_LINE count = [ 0 ] * INT_SIZE NEW_LINE