It's something like partition in quick sort.

```
public class Solution {
public void moveZeroes(int[] nums) {
int idx = -1;
for(int i = 0; i < nums.length; i++) {
if(nums[i] != 0 && ++idx != i) {
nums[idx] = nums[i];
}
}
for(int i = idx + 1; i < nums.length; i++) {
nums[i] = 0;
}
}
}
```