Zeros to the end
Easyarraytwo pointers
Move every zero to the end of the array while keeping the other elements in their original order. Return the modified array.
Example 1
Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0]
Example 2
Input: nums = [0] Output: [0]
Constraints
- 0 ≤ nums.length ≤ 10⁴
- Try to do it in place
Submit checks your solution against 7 tests, including hidden ones.
/**
* @param {int[]} nums
* @return {int[]}
*/
function moveZeros(nums) {
}