1608.Preorder Traversal

通过数:33提交数:64学校:浙江大学考研机试真题 题目列表 标签
题目描述 Suppose that all the keys in a binary tree are distinct positive integers. Given the $ postorder $ and $ inorder $ traversal sequences, you are supposed to output the last number of the $ preorder $ traversal sequence of the corresponding binary tree. 输入格式 Each input file contains one test case. For each case, the first line gives a positive integer $ N $ ($ \leq 50,000 $), the total number of nodes in the binary tree. The second line gives the $ postorder $ sequence and the third line gives the $ inorder $ sequence. All the numbers in a line are separated by a space. 输出格式 For each test case, print in one line the last number of the $ preorder $ traversal sequence of the corresponding binary tree. 输入样例 7 1 2 3 4 5 6 7 2 1 4 3 7 5 6 输出样例 5
C
补全
点击调试按钮即可调试代码。

点击提交按钮即可提交代码。