#include <iostream>
#include <algorithm>
#include "string"
#include "vector"
#include "stack"
using namespace std;
int removeDuplicates(vector<int>& nums)
{
int i = 0, j = 0;
while (j<nums.size())
{
int tmp = nums[j];
nums[i++] = nums[j++];
while (tmp == nums[j] && j < nums.size())//去除重复项
{
j++;
}
}
return i;
}
int main()
{
vector<int>v1;
v1.push_back(1);
v1.push_back(2);
v1.push_back(2);
cout << removeDuplicates(v1);
system("pause");
return 0;
}