Is this the most efficient solution? Please add suggestions


#1

int curr=1;

//int i=1;
for(int i=0;i<A.size()-1;i++){
    //cout<<" i outside is"<<i<<endl;
    
    if(A[i+1]!=A[i]){
        A[curr]=A[i+1];
        curr++;
        
        
    }
    
}

for(int i=0;i<A.size();i++){
    if(A[i+1]<=A[i]){
        curr=i+1;
        break;
    }
    
}

A.erase(A.begin()+curr,A.end());


return A.size();

#2

better can be done in one pass and without erase statement.