Give preOrder and inOrder of a binary tree, calculate the postOrder.

package com.ismdeep.tree;

public class ShiftTree {
    public static void shift(String preOrder, String inOrder) {
        if (preOrder.equals("")) return;
        char root = preOrder.charAt(0);
        String leftIn = inOrder.substring(0, inOrder.indexOf(root));
        String rightIn = inOrder.substring(inOrder.indexOf(root) + 1, inOrder.length());
        String leftPre = preOrder.substring(1, leftIn.length()+1);
        String rightPre = preOrder.substring(leftIn.length() + 1, preOrder.length());
        shift(leftPre, leftIn);
        shift(rightPre, rightIn);
        System.out.println(root);
    }

    public static void main(String[] args) {
        String preOrder = "ABDGEHCF";
        String inOrder = "GDBEHACF";
        shift(preOrder, inOrder);
    }
}
GDHEBFCA