public void rotate(char[] A, int begin, int end) {
        while (begin < end) {
            char temp = A[begin];
            A[begin] = A[end];
            A[end] = temp;
            ++begin;
            --end;
        }
    }