6. Move Zeros
Easy
Return a new array with all zeros after the non-zero values, preserving the relative order of the other values.
Example 1
Input: nums = [0,3,0,-2,8]
Output: [3,-2,8,0,0]
Example 2
Input: nums = [0,0,0]
Output: [0,0,0]
Constraints
- 0 <= nums.length <= 10000
ArraysTwo pointers
Saved in this browser
Caso 1
nums =
[0,3,0,-2,8]
Expected =
[3,-2,8,0,0]
Caso 2
nums =
[0,0,0]
Expected =
[0,0,0]
Run checks these 2 cases. Submit runs all 6, including hidden ones.