标签:rem turn tco push ack vector back res duplicate
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; } };
标签:rem turn tco push ack vector back res duplicate
原文地址:https://www.cnblogs.com/cunyusup/p/9666980.html