My 32ms clean and easy understanding solution


  • 0
    L
    int removeDuplicates(vector<int>& nums) {
    
    	if(nums.size()==0||nums.size()==1)  return nums.size();
    
    	int i=1,con=0;
    
     	for(;i<nums.size();i++){
     		if(nums[i]!= nums[con]){
     			con++;
     			nums[con] = nums[i];
     		}
     	}
    
    	return con+1;
    
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.