I have an array of 100 million 4 byte integers. The integers themselves can range from 1 to N (where
N is some arbitrary integer). There are also zeroes in the array. I am trying to devise an algorithm
that will remove the zeroes from the array and pack the remaining integers into the list.
For example, let’s say I have this list of integers
0, 0, 5, 10, 11, 12, 0, 0, 0, 20, 30, 40
I want to remove the zeroes and pack it into
5, 10, 11, 12, 20, 30, 40
I tried to use the reduction sample but I’m not getting anywhere.
Can anyone suggest an algorithm or another example I should look at?