Back to DSA

Construct Binary Tree from Preorder and Inorder Traversal

medium
Acceptance: 54%
Binary Tree

Two integer arrays representing the pre-order and in-order traversals of a binary tree are given. Both arrays contain the same set of unique values. Reconstruct the original binary tree and return its root.

Examples

Example 1:
Input:preorder = [1,2,4,5,3,6], inorder = [4,2,5,1,6,3]
Output:[1,2,3,4,5,6,null]

Hints

00:00
1234567