We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
秀哥答案里给出的解题源代码少贴了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; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
秀哥答案里给出的解题源代码少贴了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;
}
The text was updated successfully, but these errors were encountered: