public TreeNode buildTree(int[] inorder, int[] postorder) {
        if (inorder == null || postorder == null || inorder.length == 0
                || postorder.length == 0) {
            return null;
        }

        if (inorder.length == 1) {
            return new TreeNode(inorder[0]);
        }

        StringBuilder sb = new StringBuilder();
        sb.append("inorder:");
        for (int inorderelement : inorder) {
            sb.append(inorderelement);
        }
        sb.append(";postorder:");
        for (int postorderelement : postorder) {
            sb.append(postorderelement);
        }
        System.out.println(sb);
        // find the root node in postorder and the rootnode index in inorder
        int rootVal = postorder[postorder.length - 1];
        TreeNode root = new TreeNode(rootVal);
        int inorderIndex = findIndexInArr(inorder, rootVal);
        System.out.println("inorderIndex:" + inorderIndex);
        TreeNode leftChild = null;
        TreeNode rightChild = null;
        if (inorderIndex < inorder.length - 1) {
            // right child
            int[] rightChildInorder = Arrays.copyOfRange(inorder,
                    inorderIndex + 1, inorder.length);
            int[] rightChildPostorder = Arrays.copyOfRange(postorder,
                    inorderIndex, postorder.length - 1);
            rightChild = buildTree(rightChildInorder, rightChildPostorder);
            System.out.println("rightChild:" + rightChild);

        }
        if (inorderIndex > 0) {
            // left child
            int[] lefttChildInorder = Arrays.copyOfRange(inorder, 0,
                    inorderIndex);
            int[] leftChildPostorder = Arrays.copyOfRange(postorder, 0,
                    inorderIndex);
            leftChild = buildTree(lefttChildInorder, leftChildPostorder);
            System.out.println("leftChild:" + leftChild);
        }
        root.left = leftChild;
        root.right = rightChild;
        return root;
    }