标签:rem from duplicate 重复项 problems ted 代码 leetcode ++i
class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int k = 0;
for (int i = 0; i < nums.size(); ++i) {
if (!i || nums[i] != nums[i - 1]) {
nums[k++] = nums[i];
}
}
return k;
}
};
标签:rem from duplicate 重复项 problems ted 代码 leetcode ++i
原文地址:https://www.cnblogs.com/clown9804/p/13153211.html