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
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console