JavaScript Accepted O(n) Solution


  • 1
    M
    var moveZeroes = function(nums) {
    var len = nums.length;
    for (var i = 0; i<len; ++i){
        if (nums[i]===0){
            nums.splice(i,1);
            nums.push(0);
            --i;
            len--;
        }
    }};

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.