int removeDuplicates(vector<int>& nums) {
int i=0;
int n=nums.size();
for(int j=1;j<n;++j)
{if(nums[i]!=nums[j])
{ nums[i+1]=nums[j]; i++;}}
return i+1;}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter