```
public class Solution {
public void MoveZeroes(int[] nums) {
int start = 0;
while(start < nums.Length)
{
int zero = GetFirstZeroIndex(nums, start);
if (zero == -1) break;
int other = GetFirstNonZeroIndex(nums, zero + 1);
if (other == -1) break;
Swap(nums, zero, other);
start = zero + 1;
}
}
static int GetFirstZeroIndex(int[] nums, int start)
{
for(int i = start; i < nums.Length; i++)
{
if(nums[i] == 0) return i;
}
return -1;
}
static int GetFirstNonZeroIndex(int[] nums, int start)
{
for(int i = start; i < nums.Length; i++)
{
if(nums[i] != 0) return i;
}
return -1;
}
static void Swap<T>(T[] nums, int a, int b)
{
//TODO: Assert a and b are valid within range
T temp = nums[b];
nums[b] = nums[a];
nums[a] = temp;
}
}
```