Description
Submission
class Solution { public: int removeDuplicates(vector<int>& nums) { if(nums.size() < 2) return nums.size(); int currNum = nums[0]; int currCount = 0; int j = 0; for(int i = 0; i < nums.size(); ++i) { if(nums[i] == currNum) { currCount++; if(currCount < 3) { nums[j++] = nums[i]; } } else { currNum = nums[i]; currCount = 1; nums[j++] = nums[i]; } } return j; } };