leetcode-----26. 删除排序数组中的重复项
代码
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;
}
};