Move All Zeros to the End
Push every zero to the back while keeping the other values in order.
Input format
The first line has one integer N. The second line has N space-separated integers.
Output format
Move every 0 to the end while keeping the order of the non-zero elements. Print the resulting array.
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
5
0 1 0 2 3Expected output
1 2 3 0 0Example 2
Input
4
0 0 0 0Expected output
0 0 0 0