COuld you suggest me the best algorithm to remove all zeros from given array in O(n) time and without external memory.
For example, 1 2 0 0 3 2 0 2 becomes 1 2 3 2 2
COuld you suggest me the best algorithm to remove all zeros from given array
Share
use two pointers – one for read and one for write.