You are given two lists of integers:
• preorder → the preorder traversal of a binary tree
• inorder → the inorder traversal of the same tree
Your task is to construct the original binary tree from these two lists and
return its root.
Reminder:
• Preorder traversal: Root → Left → Right
• Inorder traversal: Left → Root → Right
Input: preorder = [7,4,9,12,15] inorder = [9,4,12,7,15]
Output: [7,4,null,9,12,null,15]
Explanation:
Construct the tree that matches these traversals.
Input: preorder = [5] inorder = [5]
Output: [5]
Accepted:
Submission: