New update is available. Click here to update.

Topics

You are given arrays * 'inOrder'* and

Construct a 'Binary Tree' represented by the given arrays and return it's head.

```
Assume that the Binary Tree contains only unique elements.
```

```
Input: 'inOrder' = [9, 3, 15, 20, 7], 'postOrder' = [9, 15, 7, 20, 3]
Output:
We get the following binary tree from Inorder and Postorder traversal:
```

Detailed explanation

```
7
4 5 2 6 7 3 1
4 2 5 1 6 3 7
```

```
1 2 3 4 5 6 7
```

```
We get the following Binary Tree from the given Inorder and Postorder traversal:
```

```
6
2 9 3 6 10 5
2 6 3 9 5 10
```

```
5 6 10 2 3 9
```

```
We get the following Binary Tree from the given Inorder and Postorder traversal:
```

```
Try to solve this in O(n).
```

```
1 <= 'n' <= 10000
1 <= 'inOrder[i]' , ‘postOrder[i]’ <= 100000
Time Limit: 1 second
```