public static void sortColors(int[] A) {//accepted
        if (A == null || A.length < 2) return;
        int pleft = 0, pright = A.length-1;
        for (int p = 0; p <= pright; p++) {
            if (A[p] == 0) {
                int temp = A[p];
                A[p] = A[pleft];
                A[pleft] = temp;
                pleft++;
            }
            else if (A[p] == 2) {
                int temp = A[p];
                A[p] = A[pright];
                A[pright] = temp;
                pright--;
                p--;
            }
        }
        showArray(A);
    }