My simple java solution


  • 0
    C

    public class Solution {

    public int removeDuplicates(int[] A) {
    
    	int N = A.length;
    	int end = 1;   	
    	int count = 0;
    	while (end < N)
    	{
    		while (end < N && A[end] == A[count]) end++;
    
    		if (end < N)
    			A[++count] = A[end];
    		end++;
    	}
        return Math.min(++count,N);
    }
    

    }


Log in to reply
 

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