Move Zeroes to End
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Sample case — your program reads stdin and prints to stdout.
Given an array of integers, move all zeroes to the end while maintaining the relative order of non-zero elements.
Use two pointers: one for the position to insert non-zero, one to scan.
Example: [0,1,0,3,12] → [1,3,12,0,0]
Input format
Line 1: n. Line 2: n space-separated integers.
Output format
The array with zeroes moved to end, space-separated.
Constraints
1 ≤ n ≤ 10⁴