You are given the postorder and inorder traversal of a binary tree. Your job is to reconstruct the tree and print the preorder traversal of the tree.
Note
Each input is given in three lines.
The first line contains an integer n
: The number of vertices of the binary tree.
The second line is the postorder traversal of the tree.
The last line is the inorder traversal of the tree.
Note
Restriction
Output should be printed in one line. Containing the preorder traversal of the tree. Each vertex of the traversal should be seperated with an empty space.
Remember to print a ‘\n’ at the end of the output.
Do not include any spaces at the "end of line".