move zeros
2022年5月1日小于 1 分钟
move zeros
Question
Given an array of integers, move zeros to the end while keeping the order of the rest.
You should make the in-place change.
const list = [1,0,0,2,3]
moveZeros(list)
console.log(list) // [1,2,3,0,0]
What is the time & space complexity of your approach?
Code
/**
* @param {Array<any>} list
* @returns {void}
*/
function moveZeros(list) {
// your code here
}