public class Solution {
    public void moveZeroes(int[] nums) {
        int start = 0;
        for (int n: nums) {
            if (n != 0) {
                nums[start] = n;
                start++;
            }
        }

        for (; start < nums.length; start++) {
            nums[start] = 0;
        }
    }
}

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

optimize #283