码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] 889. Construct Binary Tree from Preorder and Postorder Traversal 由先序和后序遍历建立二叉树

时间:2019-05-23 00:01:38      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:can   osi   post   blog   参考   note   not   problems   tps   



Return any binary tree that matches the given preorder and postorder traversals.

Values in the traversals?pre?and?post?are distinct?positive integers.

Example 1:

Input: pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1]
Output: [1,2,3,4,5,6,7]

Note:

  • 1 <= pre.length == post.length <= 30
  • pre[]?and?post[]?are both permutations of?1, 2, ..., pre.length.
  • It is guaranteed an answer exists. If there exists multiple answers, you can return any of them.



类似题目:

Construct Binary Tree from Inorder and Postorder Traversal

Construct Binary Tree from Preorder and Inorder Traversal



参考资料:

https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/



LeetCode All in One 题目讲解汇总(持续更新中...)

[LeetCode] 889. Construct Binary Tree from Preorder and Postorder Traversal 由先序和后序遍历建立二叉树

标签:can   osi   post   blog   参考   note   not   problems   tps   

原文地址:https://www.cnblogs.com/grandyang/p/10909191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!