Skip to content

Instantly share code, notes, and snippets.

@pitsanujiw
Created January 11, 2021 09:24
Show Gist options
  • Save pitsanujiw/fd749349185dc82644d9ebe8809e1208 to your computer and use it in GitHub Desktop.
Save pitsanujiw/fd749349185dc82644d9ebe8809e1208 to your computer and use it in GitHub Desktop.
public class Solution {
public void MoveZeroes(int[] nums) {
int indexSwap = 0;
for (int i = 0; i < nums.Length; i++)
{
if (nums[i] != 0)
{
if (i != indexSwap)
{
nums[indexSwap] = nums[i];
nums[i] = 0;
}
indexSwap++;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment