LeetCode 26. Remove Duplicates from Sorted Array
很简单。
class Solution { public: int removeDuplicates(vector<int>& a) { int n=a.size(); if (!n) return 0; int i=0,j=1; while(j<n){ if(a[j]>a[i]) {a[++i]=a[j];j++;} else j++; } while(a.size()>i+1) a.pop_back(); return i+1; } };