Title Description
And enter the result in a preorder traversal of a binary tree in preorder traversal of the binary tree a rebuild. Suppose Results preorder traversal order and input of duplicate numbers are free. Before entering e.g. preorder traversal sequence {1,2,4,7,3,5,6,8} and {4,7,2,1,5,3,8,6} order traversal sequence, and the reconstructed binary tree return.
Problem-solving ideas
The first value is the value of the preorder traversal of the root node, this value will be used in order traversal results divided into two parts, the left part of the left subtree of the tree in preorder a result, the right part of the right subtree of the tree in preorder the result of.