LeetCode-Construct Binary Tree from Inorder and Postorder Traversal
Construct Binary Tree from Inorder and Postorder Traversal
##题目
####Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.
####Note:
You may assume that duplicates do not exist in the tree.
##解题思路
该题和Construct Binary Tree from Preorder and Inorder Traversal的解法类似,只不过后序中最后一个节点才是根结点,因此与前序的差别是需要从后往前遍历。代码与Construct Binary Tree from Preorder and Inorder Traversal非常类似。
##算法代码
代码采用JAVA实现:
1 | /** |