Back

Move Zero element at end of Array

Copy Below Code View As A Text File Show Text Only Show API Edit Code
                            

== Q == https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/567/ = Solution = /** * @param {number[]} nums * @return {void} Do not return anything, modify nums in-place instead. */ var moveZeroes = function(nums) { var left=0; var right=0; var temp; while(right <=nums.length-1){ if(nums[right] === 0){ right++; } else{ temp = nums[left]; nums[left]=nums[right]; nums[right]=temp; left++; right++; } } };