public class Solution {
public void sortColors(int[] A) {
int len=A.length;
int beg=0;
int end=len-1;
int cur=0;
while(cur<=end){
if(A[cur]==0)
{
swap(A,cur,beg);
beg++;
cur++; }
else if(A[cur]==1)
{
cur++; }
else
{
swap(A,cur,end);
end--; } }
}
public void swap(int[] A,int i,int j)
{
int temp=A[i];
A[i]=A[j];
A[j]=temp; } }