Problem C: Pre, in and post
Problem C: Pre, in and postTime Limit: 1 Sec Memory Limit: 128 MB
Submit: 1053 Solved: 460
You are given the pre-order and in order traversal of the binary tree, please find the post-order of this tree.
The first line will be an integer \(T (1 \leq T \leq 10)\), which is the number of test cases.
For each test data:
The first line contains one integer \(N (1 \leq N \leq 10^3)\) — the number of nodes of the tree
Then follows two lines:
The first line contains N integers ranging from 1 to N, indicating the pre-order traversal of the tree.
The second line contains N integers ranging from 1 to N, indicating the in-order traversal of the tree.
For each case, contains one line with N integer, the post-order traversal of the tree.
1 2 4 3 5
2 4 1 5 3
4 2 5 3 1