Factual interview question

Write an algorithm to compact an array