ArrayTwo Pointers
Move every 0 in the array to the end while keeping the relative order of the non-zero elements.
Input
Line 1: n. Line 2: n space-separated integers.
Output
Print the rearranged array on one line, separated by spaces.
Constraints
1 <= n <= 10^5 -10^9 <= each value <= 10^9
Example 1
Input
5 0 1 0 3 12
Output
1 3 12 0 0
The zeros move to the back; 1, 3, 12 keep their order.