Given an array nums write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
/// <summary>
/// Given an array nums write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements
/// </summary>
/// <param name="nums"></param>
static void MoveZeros(int[] nums)
{
int index = 0;
for(var i = 0; i < nums.Length; i++)
{
if (nums[i] != 0)
{
nums[index++] = nums[i];
}
}
for(var i = index; i < nums.Length; i++)
{
nums[i] = 0;
}
}