InterviewGuide icon indicating copy to clipboard operation
InterviewGuide copied to clipboard

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

Open tjl8787 opened this issue 2 years ago • 0 comments

秀哥答案里给出的解题源代码少贴了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; }

tjl8787 avatar Dec 03 '23 06:12 tjl8787