题目地址:https://leetcode-cn.com/problems/remove-duplicates-from-sorted-array/
解题思路:设计标记。
class Solution { public: int removeDuplicates(vector<int>& nums) { if(nums.size() == 0) return 0; int idx = 0; int tmp = nums[0]; for (int i = 1; i < nums.size(); i++) if (nums[i] != tmp) { nums[++idx] = nums[i]; tmp = nums[i]; } return idx+1; } };