class Solution { public: int removeDuplicates(vector<int>& nums) { int res = 0; nums.push_back(INT_MAX); //注意末尾的补位 for(int i=0;i < nums.size()-1;i++){ if(nums[i] != nums[i+1]){ nums[res] = nums[i]; res++; } } return res; } };