Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

精选leecode300+算法题 双指针80题 #139

Open
tjl8787 opened this issue Dec 3, 2023 · 0 comments
Open

精选leecode300+算法题 双指针80题 #139

tjl8787 opened this issue Dec 3, 2023 · 0 comments

Comments

@tjl8787
Copy link

tjl8787 commented Dec 3, 2023

秀哥答案里给出的解题源代码少贴了len>=2的解题部分,自己在参考时,尝试作了补充,补充后的代码如下:
int removeDuplicates(vector& nums) {
int len=0;
for(unsigned i=0;i<nums.size();i++){
if(len<2){
nums[len++]=nums[i];
}
else{
if(nums[i]!=nums[len-2]){
nums[len++]=nums[i];
}
}
}
return len;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant