Question
The Ghost Tile March
After a parade, the ground crew must restore order to a row of
The operation must be done in-place with no extra array. The relative order of non-zero tiles must be preserved.
Input
The first line contains KaTeX can only parse string typed expression. The second line contains KaTeX can only parse string typed expression space-separated integers.
Output
KaTeX can only parse string typed expression space-separated integers — the rearranged row.
Example
Example 1:
Input
Example 2:
Input
Input
5
0 1 0 3 12Output1 3 12 0 0Example 2:
Input
3
0 0 0Output0 0 0