Move Zeroes | LeetCode 283

AFFILIATE LINKS

Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard

/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
let moveZeroes = function(nums) {
    let anchor = 0;
    
    for (let explorer = 0; explorer < nums.length; explorer++) {
        if (nums[explorer] !== 0){
            let temp = nums[anchor];
            nums[anchor] = nums[explorer];
            nums[explorer] = temp;

            anchor++;
        }
    }
}