**Problem question:** Given the sequence A and B, where A is the inorder traversal value and B is the pre-order traversal value, reconstruct the binary tree that produces such results when performing inorder and pre-order traversal on that binary tree. To reconstruct the binary tree you can simply print the breadth-first traversal of the reconstructed tree. You can assume that the size of A and B is 2n+1, that is, its a complete and full binary tree.

Example :

input:

A = 1 2 3 4 5 6 7 #in order traversal

B = 4 2 1 3 6 5 7 #pre order traversal

output:

Bredth-first tree: 4 2 6 1 3 5 7.

Note the tree looked like :

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

Bonus: For fast implementation in terms of speed and memory!