整體不難俭尖,非常簡單
654.?Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:
The root is the maximum number in the array.
The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
Construct the maximum tree by the given array and output the root node of this tree.
按照規(guī)則產(chǎn)生樹:最大的為根節(jié)點(diǎn)割粮,根節(jié)點(diǎn)左邊構(gòu)成左子樹,右邊構(gòu)成右子樹
105.?Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.
注意根節(jié)點(diǎn)的位置和長度的對應(yīng)關(guān)系即可
106.?Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tree.