Thursday, October 2, 2014

Construct Binary Tree from Inorder and Postorder Traversal

Problem

Given inorder and postorder traversal of a tree, construct the binary tree.

Note:
You may assume that duplicates do not exist in the tree.

Idea

和之前那个inorder和preorder建树的思路一样,在preorder里找根,在inorder里找左子树右子树.

Solution


No comments:

Post a Comment