Javascript Solution Beats 93%. O(N) time and O(1) space


  • 0
    H
    var moveZeroes = function(nums){
      for (var i = 0; i < nums.length; i++){
        if (nums[i] !== 0){
          var temp = nums[j];
          nums[j] = nums[i];
          nums[i] = temp;
        }
      }
    }

Log in to reply
 

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