Construct Binary Tree from Preorder and Inorder Traversal

Problem

Given preorder and inorder traversal of a tree, construct the binary tree.

Have you met this question in a real interview? Yes Example Given in-order [1,2,3] and pre-order [2,1,3], return a tree:

  2
 / \
1   3

思路

Solution