C solution, 12ms


  • 1
    B
    int removeDuplicates(int* nums, int numsSize) {
        int counter = 0;
        for(int i = 0; i < numsSize - 1; ++i)
        {
            if(nums[i] == nums[i + 1]) counter++;
            else nums[i - counter + 1] = nums[i + 1];
        }
        
        return numsSize - counter;
    }

Log in to reply
 

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