283. Move Zeroes

202409012145
tags: #two-pointers

var moveZeroes = function(nums) {
	let len = 0;
	for (let i = 0; i < nums.length; i++) {
		if (nums[i] !== 0) {
			nums[len] = nums[i];
			if (i !== len) {
				nums[i] = 0;
			}
			len += 1;
		}
	}
};

Reference

https://leetcode.com/problems/move-zeroes