Skip to content

Instantly share code, notes, and snippets.

@XcqRomance
Created December 3, 2018 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XcqRomance/5599107f5f7d21bbc1dea5f9544bb0d4 to your computer and use it in GitHub Desktop.
Save XcqRomance/5599107f5f7d21bbc1dea5f9544bb0d4 to your computer and use it in GitHub Desktop.
// 7.移动零
void moveZeroes(int* nums, int numsSize) {
if (numsSize <= 0) {
return;
}
int j = 0 ;
for (int i = 0; i < numsSize; i++) {
if (nums[i]) {
nums[j++] = nums[i];
}
}
for (int i = j ; i < numsSize; i++) {
nums[i] = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment