public static void sortColors(int[] A) {
        int i = 0, j = A.length - 1;
        int curr = i;
        while(curr <= j){
            if(A[curr] == 0){
                if(curr > i){
                    swap(A, curr, i++);
                }else{
                    curr++;
                    i++;
                }
            }else if(A[curr] == 2){
                if(curr < j){
                    swap(A, curr, j--);
                }else{
                    return;
                }
            }else if(A[curr] == 1){
                curr++;
            }
        }
    }