时间*度为o(n),空间*度为o(1);
class Solution {
public:
/**
* @param A: a list of integers
* @return : return an integer
*/
int removeDuplicates(vector<int> &nums) {
// write your code here
if(nums.empty())
{
return 0;
}
int n = nums.size(),k=0;
for(int i=1;i<n;++i)
{
if(nums[i] != nums[k])
{
nums[++k] = nums[i];
}
}
nums.resize(k+1);
return k+1;
}
};