Created
December 3, 2018 07:07
-
-
Save XcqRomance/de9e5ba7fbac6ae5f37bdd2dd4015c15 to your computer and use it in GitHub Desktop.
1.从排序数组中删除重复项
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
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