Easy to understand solution cpp(title)


#1

Commenint zero=0;
int two=A.size()-1; int i=0;
while(i<=two)
{
if(A[i]==0)
{ swap(A[i], A[zero]); zero++; i++;}
else if(A[i]==2)
{ swap(A[i], A[two]); two–;}
else if(A[i]==1)
{i++;}
}t body goes here.