for(i=0; i<A.size()-1; i++)
This will throw a segfault as A.size() keeps changing as you keep erasing. So i will try to access memory locations that you have removed
Instead “while” use “if” loop. This will resolve run time error.
Just few modications which will avoid runtime error.
while( i < A.size()-1 && A[i]==A[i+1] )
A.erase( A.begin() +i +1 );