F3a8553749a34b5105c866ce3a9a7766
(难度Medium) Problem 106. Construct Binary Tree from Inorder and Postorder Traversal(中序和后序还原二叉树)

Construct Binary Tree from Inorder and Postorder Traversal

Difficulty

Medium

Description

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

题意

这道题和上一题的题意类似,在上一题当中我们给定了二叉树的中序和先序的遍历结果,要求返回这棵二叉树。

这一题稍稍做了一些改动,给定先序和后序遍历的结果,要求返回生成的二叉树。

题解

top Created with Sketch.