#C10713. Move Zeroes

    ID: 39949 Type: Default 1000ms 256MiB

Move Zeroes

Move Zeroes

Given an array of integers, your task is to move all the 0's to the end of the array while maintaining the relative order of the non-zero elements. This must be done in-place without making a copy of the array.

For example, if the array is [0, 1, 0, 3, 12], then after processing it should become [1, 3, 12, 0, 0].

Note: You must achieve this by modifying the input array directly.

inputFormat

The input is read from stdin and is structured as follows:

  1. An integer n on the first line, representing the number of elements in the array.
  2. A second line with n space-separated integers.

outputFormat

Output the modified array to stdout as a single line of space-separated integers after moving all zeros to the end.

## sample
5
0 1 0 3 12
1 3 12 0 0