99: Construct a binary tree from preorder and inorder traversal

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

Note: binary tree does not have duplicates

 

Example 1

Input:   preoder = [1, 2, 3], inporder = [2, 1, 3]

Output:    1
          / \
         2   3

Example 1

Input:   preoder = [1, 2, 3], inporder = [3, 2, 1]

Output:    1
            \
             2
              \
               3
Difficulty:Medium
Topic:Tree
Problem #:99