Why my code is wrong ? however it runs well in my linux?


  • 0
    W
    int removeDuplicates(int A[], int n) {
    int len = 0;
    int flag;
    if(n == 0)return n;
    len = 1;
    flag = A[0];
    for(int i = 1 ; i < n; i++)
    {
    	while(A[i] == flag)i++;
    	if(i == n)break;
    	else {
    		flag = A[i];
    		A[len++] = flag; 
    	}
    }
    return len;
    

    }


Log in to reply
 

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