Help!

Binary tree level traversal 2

【Question Description】
 

    For a binary tree, its pre-order traversal is ABDEGCFHI, and its in-order traversal is DBGEACHFI, and the result of its hierarchical traversal is ABCDEFGHI.

    It can be proved that, given the known preorder and inorder traversal, the result of a binary tree and its level traversal can be uniquely determined. According to the given pre-order and in-order traversal, output the result of the hierarchical traversal of this binary tree.

 

【Enter description】

    The first line is a string representing the preorder traversal of the binary tree.

    The second line is a string representing the in-order traversal of the binary tree.

    The nodes of a binary tree are always represented by uppercase or lowercase letters, and the number of nodes is not more than 100.

[Output description]

    Output the level traversal of the binary tree, one line of characters.

【Input sample】

    ABDEGCFHI

    DBGEACHFI

【Example of output】

    ABCDEFGHI

 how to do it

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325389654&siteId=291194637