Easy15 pts
Move Zeroes to End
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
Line 1: n. Line 2: n space-separated integers.
Output
The array with zeroes moved to end, space-separated.
Sample
5 0 1 0 3 12
Expected
1 3 12 0 0
Loading editor…
Output
No output yet. Run your code to see results.