//打下划线太麻烦了换一下标题风格
//请注意nums.end()返回的是向量最后一个元素的后面那个地址
//太坑了
//要好好学习
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
if (nums.size() == 0) return 0;
if (nums.size() == 1)return 1;
vector<int>::iterator it = nums.begin();
int deleted = 0;
while(true) {
//vector<int>::iterator it;
if (it != nums.end()-1) {
if (*it == *(it + 1)) {
it = nums.erase(it);
deleted++;
continue;
}
else {
it++;
if (it == nums.end()-1)break;
else continue;
}
}
else {
if (size(nums) == 1)break;
else {
if (*it == *(it - 1)) {
it = nums.erase(it - 1);
deleted++;
break;
}
else { break; }
}
}
}
return size(nums);
}
};