1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
var moveZeroes = function(nums: number[]): void { let start = 0; let end = nums.length - 1; while (start < end) { if (nums[start] === 0) { nums.push(0); nums.splice(start, 1); end--; continue; } start++; } };
|