https://leetcode.com/problems/remove-duplicates-from-sorted-array/
双指针,注意初始时左右指针指向首元素!
class Solution { public: int removeDuplicates(vector<int>& nums) { int n=1; int i = nums.size(); if(i == 0) return 0; int *l = &nums[0],*r = &nums[0]; while(*r != nums[i-1]) { while(*l == *r) { r++; } l++; *l = *r; n++; } return n; } };