C++ Easy Solution


  • 0
    K

    class Solution {

    public:

    int removeDuplicates(vector<int>& nums) {
        int size=nums.size();
        int i=0,j=0;
        while(i<size){
            nums[j++]=nums[i];
            while(i+2<size && nums[i]==nums[i+1] && nums[i+1]==nums[i+2]){
                i++;
            }
            i++;
        }
        return j;
    }
    

    };


Log in to reply
 

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