Construct Binary Tree From Inorder And Levelorder Traversal

medium
1. You are given a partially written function to solve(Refer question video).
2. Task : Construct Binary Tree from InOrder and LevelOrder Traversal.
3. you will be given two arrays representing a valid InOrder & LevelOrder of a Binary Tree. Program is required to create a unique Binary Tree.

Input Format

Input is managed for you.

Output Format

Output is managed for you.

Constraints

0 <= Number of Nodes <= 10^9
-10^9 <= value of Node data <= 10^9
Valid InOrder and LevelOrder traversals.

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
9
2 7 15 12 6 9 5 11 4
12 7 5 6 11 2 15 4 9
Output
7 -> 12 <- 5
2 -> 7 <- 15
. -> 2 <- .
. -> 15 <- .
6 -> 5 <- 11
. -> 6 <- 9
. -> 9 <- .
. -> 11 <- 4
. -> 4 <- .
Previous
All Nodes Distance K In Binary Tree
Next
Burning Tree

Related Questions