Leetcode 105. Construct Binary Tree From Preorder And Inorder Traversal
You are given two integer arrays `preorder` and `inorder`.
* `preorder` is the preorder traversal of a binary tree
* `inorder` is the inorder traversal of the same tree
* Both arrays are of the same size and consist of unique values.
Rebuild the binary tree from the preorder and inorder traversals and return its root.
Examples
Example 1
Input: preorder = [1], inorder = [1]
Output: [1]
Constraints
- `1 <= inorder.length <= 1000`.
- `inorder.length == preorder.length`
- `-1000 <= preorder[i], inorder[i] <= 1000`
How the tests work: the tree you return is read back as a level-order array —
[3,9,20,null,null,15,7].