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 .
byte sizeof_int = 4 ; int INT_SIZE = 8 * sizeof_int ; int [ ] count = new int [ INT_SIZE ] ;