Skip to content

Latest commit

 

History

History
61 lines (39 loc) · 1.72 KB

0106-construct-binary-tree-from-inorder-and-postorder-traversal.adoc

File metadata and controls

61 lines (39 loc) · 1.72 KB

106. Construct Binary Tree from Inorder and Postorder Traversal

{leetcode}/problems/construct-binary-tree-from-inorder-and-postorder-traversal/[LeetCode - 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.

For example, given

inorder = [9,3,15,20,7]
postorder = [9,15,7,20,3]

Return the following binary tree:

    3
   / \
  9  20
    /  \
   15   7

解题分析

使用递归,从底层向上构建整个树。

{image_attr}
{image_attr}

参考资料

link:{sourcedir}/_0106_ConstructBinaryTreeFromInorderAndPostorderTraversal.java[role=include]
link:{sourcedir}/_0106_ConstructBinaryTreeFromInorderAndPostorderTraversal_2.java[role=include]
{image_attr}