- We have all the numbers in a 32-bit format stored internally
- Iterate through columns (of bits) of all numbers (using bitwise shifts)
- Count number of 1’s and 0’s each (using bitwise AND)
- Make pairs, we can have 4 scenarios -> (0,0) , (1,1), (0,1) , (1,0)

We specifically need the last 2 scenarios, which would be -

No. of zeros * No. of ones + No. of ones * No. of zeros

i.e 2XY (X is no. of zeros, Y is no. of ones)

and voila we have our solution.

The solution uses bitwise shift operator and we do not really need to convert numbers to binary as that’s how they are actually stored in the computer.