Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * @param {number[]} nums
  3.  * @return {void} Do not return anything, modify nums in-place instead.
  4.  */
  5. var moveZeroes = function(nums) {
  6.     let i = 0, max = nums.length;
  7.    
  8.     while(i < max) {
  9.         if (nums[i] === 0) {
  10.             nums.splice(i, 1);
  11.             nums.push(0);
  12.             max--;
  13.         } else {
  14.             i++;
  15.         }
  16.     }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement