4
int n; // nth post order node6
public TreeNode buildTree(int[] inorder, int[] postorder) {7
this.n = inorder.length - 1;10
return buildTree(0, n);13
public TreeNode buildTree(int low, int high) {14
if (n < 0 || low > high) return null;15
int currNode = po[n--];16
int idxInInorder = low;17
TreeNode root = new TreeNode(currNode);18
if (low == high) return root; // no more nodes20
while (io[idxInInorder] != currNode) idxInInorder++; // find index of currNode in inorder21
root.right = buildTree(idxInInorder + 1, high);22
root.left = buildTree(low, idxInInorder - 1);