105. Construct Binary Tree from Preorder and Inorder Traversal
Solutions
The solution is similar to divide and conquer.
- Find the root by using pre-order traversal. Find the root’s index in in-order traversal.
- Divide in-order by the index and continue.
Optimization Can use dictionary to store the index of in-order array{num: idx}
and use iterater for pre-order traversal.