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
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.