Created
January 11, 2021 09:24
-
-
Save pitsanujiw/fd749349185dc82644d9ebe8809e1208 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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