/**
* @param {number[]} nums
* @return {number}
*/
var removeDuplicates = function(nums) {
let l = 0 , r = 0 ;
while (r < nums.length){
let count = 1 ;
while(r+1<nums.length && nums[r]== nums[r+1]){
count++;
r++;
}
let times = Math.min(count,2);
while(times>0){
nums[l] = nums[r];
l++
times--;
}
r = r + 1
}
return l;
};
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)