Given an integer array nums, move all 0s to the end while maintaining the relative order of non-zero elements. Do it in-place.

Input: [0,1,0,3,12] → Output: [1,3,12,0,0]Input: [0] → Output: [0]

Slow pointer tracks the position for the next non-zero element. Fast pointer scans all elements. When fast pointer finds a non-zero, swap with slow pointer and advance both.

class Solution { public void moveZeroes(int[] nums) { int slow = 0; for (int fast = 0; fast < nums.length; fast++) { if (nums[fast] != 0) { int tmp = nums[slow]; nums[slow] = nums[fast]; nums[fast] = tmp; slow++; } } } }