Move Zeroes

Easy
Arrays Array Two Pointers

Given an array, move all zeros to end while maintaining order of non-zero elements. Print space-separated.

Constraints

1 ≤ nums.length ≤ 10^4

Examples

Example 1:
Input: 0 1 0 3 12
Output: 1 3 12 0 0
Example 2:
Input: 0
Output: 0
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.