Move Zeroes
Given an integer array nums, move all 0s to the end of it while keeping the relative order of the non-zero elements.
Do this in place: modify nums directly and don't return anything (the tests read nums after your function returns). Don't make a copy of the array.
Constraints
1 <= nums.length <= 10^4-2^31 <= nums[i] <= 2^31 - 1
Examples
Example 1
Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0]
The non-zero values 1, 3, 12 keep their order; the two zeroes go to the end. The test checks nums after your function returns.
Example 2
Input: nums = [0] Output: [0]
Example 3
Input: nums = [1,2,3] Output: [1,2,3]
JavaScript you'll use: Arrays: create, read, update Destructuring, spread and rest
/**
* @param {number[]} nums
* @return {void}
*/
function moveZeroes(nums) {
}
Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.