11427 - DS QUIZ3(2)   

Description

Given several inorder and postorder traversal sequences of a binary tree,

write a program to construct trees and output the tree height.

Each node is represented by a 32-bit integer.

Time limit: 1sec.

Input

The input is the inorder and postorder traversal sequences of a binary tree.

In each test case, there are 2 lines.

The inorder traversal sequence of the tree is in the first line, and the postorder one is in the second.

 

Note:The total number of nodes in a tree will not exceed 20000.

Output

For each tree, please output the height of the tree in a line.

Note that the height of one single root tree is 0.

Sample Input  Download

Sample Output  Download

Tags




Discuss