The forty-third day: buckle problem 283, move zero
Address: leetcode-cn.com/problems/mo…
Go to zero and zero
var moveZeroes = function(nums) {
let a = nums.length;
for(let i = 0; i < a; i++)
{
if(nums[i] === 0)
{
nums.splice(i,1);
nums.push(0);
i--;
a--;
}
}
return nums;
};
Copy the code
Execution time: 84 ms, beating 94.28% of all JavaScript commits
Memory consumption: 39.2 MB, beating 34.99% of all JavaScript commits