Two pointers: write non-zeros forward, then fill the rest with zeros.
Input
5 0 1 0 3 12
Output
1 3 12 0 0
1 0
0