my solution


  • 0
    T

    public class Solution {
    public int removeDuplicates(int[] nums) {
    int count = 1;
    int a = 1;
    for(int i = 1; i < nums.length; i++){
    if(nums[i] == nums[i-1]){
    if(a < 2)
    nums[count++] = nums[i];
    a++;
    }else{
    nums[count++] = nums[i];
    a = 1;
    }
    }
    return count;
    }
    }


Log in to reply
 

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