# 26. Remove Duplicates from Sorted Array

class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int n=nums.size();
int  i,k=0,length=n;
for(i=1;i<n;i++)
{
if(nums[i]==nums[i-1-k])
k++;
else
nums[i-k]=nums[i];
}
length=n-k;
while(k)
{
nums.pop_back();
k--;
}
return length;
}
};

#### [leetcode-26]Remove Duplicates from Sorted Array(C)

2015-07-28 12:36:07

#### Leetcode_26_Remove Duplicates from Sorted Array

2014-11-27 23:21:40

#### LeetCode 26 — Remove Duplicates from Sorted Array（C++ Java Python）

2014-02-23 15:12:20

#### 26. Remove Duplicates from Sorted Array (python)

2016-10-30 15:58:23

#### LeetCode-26 Remove Duplicates from Sorted Array(水题-去相同元素)

2015-04-29 17:29:39

#### [C++]LeetCode 26: Remove Duplicates from Sorted Array（有序数组去重）

2015-05-02 21:43:54

#### Remove Duplicates from Sorted Array -- LeetCode

2014-02-27 05:12:22

#### Remove Duplicates from Sorted Array [python解]

2017-07-24 19:18:55

#### LeetCode Remove Duplicates from Sorted Array(C语言O(n)解法)

2015-03-10 15:03:38

#### 【Leetcode Problem 26】之Remove Duplicates from Sorted Array

2017-08-17 16:28:34