【题解】
沙比提
【代码】
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
if (nums.empty()) return 0;
int idx = 0;
int len = nums.size();
for (int i = 1;i < len;i++)
if (nums[i]!=nums[i-1]){
nums[++idx] = nums[i];
}
return idx+1;
}
};
原文地址:https://www.cnblogs.com/AWCXV/p/11828333.html
时间: 2024-10-09 00:38:22