Construct BT from Preorder and Inorder
Medium
Trees
Array
Tree
DFS
Hash Table
Build tree from preorder and inorder. Output level-order.
Constraints
1 ≤ n ≤ 3000
Examples
Example 1:
Input: 3 9 20 15 7
9 3 15 20 7
Output: 3 9 20 null null 15 7
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console