class Solution { public: removeDuplicates(vector<int> &nums) { // write your code here if(nums.empty()) { return 0; }//if int n=nums.size(),k=0; for(int i=1;i<n;++i) { if(nums[i] !=nums[k]) { nums[++k]=nums[i]; }//if }//for nums.resize(k+1); return k+1; } };