Rebuild the binary tree - Offer to prove safety

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.

 

 

Cattle off-line programming problem

cyc2018 problem-solving ideas

Guess you like

Origin www.cnblogs.com/yuyu97513/p/11494534.html