Passing all test cases except [0,0](one where all the elements are same).Please help to find out the problem.Error: Segmentation Fault for Test Case:[ 0, 0]

Passing all test cases except [0,0](one where all the elements are same).Please somebody help to find out the problem.Error: Segmentation Fault for Test Case:[ 0, 0]

if(A.size()!= 1)
{
for(int i = 0; i <= A.size() - 2; i++){
int j = i + 1;
while(A[i] == A[j]){
A.erase(A.begin() + j);
if((A.size() - 1) == i){
break;
}
}

    }
}
return A.size();
Click here to start solving coding interview questions