Problem
1 | Given preorder and inorder traversal of a tree, construct the binary tree. |
Solution
Sol Recursion + 2 pointers
preorder can tell us the root, and inorder can tell us the order of left right trees.
Using 2 pointers to set the size of sub-problem.
1 | # Definition for a binary tree node. |