Solution to Construct Binary Tree from Jobdu

31 Jul

Question (in Chinese):

Question Name: Construct Binary Tree

Question Description: With the result of  pre-order and in-order traversal of a tree, construct the binary tree, and return its post-order traversal result..

Input: may contain multiple test cases. For each test case, the first line contains one integer n (1<=n<=1000), being the number of nodes in the binary tree. The second line is n integers (in the range of [1, 1000]), being the pre-order traversal result. The third line is the in-order traversal result.

Output: the post-order traversal result.

This question is completely the same as Construct Binary Tree from Preorder and Inorder Traversal by LeetCode.

Leave a Reply

Your email address will not be published. Required fields are marked *