Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.
(根据中序遍历和后序遍历构建二叉树)
Example:
1. 递归
递归构建二叉树,首先根据后序遍历确定根节点,在根据中序遍历定位到根节点。其中,中序遍历根节点左边的为左子树,右边的为右子树。具体实现过程如下:
1 | # Definition for a binary tree node. |