Skip to content

Instantly share code, notes, and snippets.

@XcqRomance
Created December 3, 2018 07:07
Show Gist options
  • Save XcqRomance/de9e5ba7fbac6ae5f37bdd2dd4015c15 to your computer and use it in GitHub Desktop.
Save XcqRomance/de9e5ba7fbac6ae5f37bdd2dd4015c15 to your computer and use it in GitHub Desktop.
1.从排序数组中删除重复项
int removeDuplicates(int* nums, int numsSize) {
if (numsSize <= 0) {
return 0;
}
int j = 0;
for (int i = 1; i < numsSize; i++) {
if (nums[j] == nums[i])
continue;
nums[++j] = nums[i];
}
return j+1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment