Given preorder and inorder traversal of a tree, construct the binary tree.
解法1: Recursive
Preorder的顺序是root,left,right
inorder的顺序是left,root,right
可见preorder的第一个一定是root,这样有了root的数值,我们就可以在inorder中找到root的位置,左边都是left,右边都是right
对左右子树同时进行tree construction。要注意的是下标容易出错, 要注意。
C++
Java