This commit is contained in:
唐树森 2018-09-01 18:34:20 +08:00 committed by GitHub
parent c5731cf829
commit 8ea58a33c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,11 @@
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
if(nums.empty()) return 0;
int count = 0;
for(int i = 1; i < nums.size(); i++){
if(nums[i] != nums[count]) nums[++count] = nums[i];
}
return count+1;
}
};