My C++ Solution Code, 33ms


  • 2
    A
     class Solution {
            public:
            int removeDuplicates(int A[], int n){
                if(NULL == A || 0 == n) return 0;
                int p = 1;
                for(int i=1; i<n; i++)
                     if(A[i-1] != A[i])
                         A[p++] = A[i];
                }
                return p;
     };

Log in to reply
 

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