Why my Java solution didn't work out here.


  • 0
    B

    public int removeDuplicates(int[] A) {
    int num = A[0];
    int length = A.length;

            for(int i = 1; i < A.length; i++){
                if(num == A[i]){
                    length--;
                }else{
                    num =A[i];
                }
            }
            
            return length;
            
        }

Log in to reply
 

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