javascript solution


  • 0
    E

    This is my javascript in-place solution:

    var moveZeroes = function(nums) {
        let len = nums.length;
    
        for (let 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.