Short nice solution


  • 0
    M
    class Solution {
    

    public:
    int removeDuplicates(int A[], int n) {

      int d=1;
      
      for(int i=1;i<n;i++)
       if(A[i]!=A[i-1]) A[d++]=A[i];
          
      
      
      return n<d?n:d;
        
    }
    

    };


Log in to reply
 

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