Given inorder and postorder traversal of a tree, construct the binary tree.
Example:
inorder:[9,3,15,20,7]
postorder:[9,15,7,20,3]
output :[3,9,20,null,null,15,7]
解释下题目:
给定先序遍历和后序遍历的,求符合要求的二叉树。
1. D&C
实际耗时:1ms
//等优化后再来写
踩过的坑:
思路
Given inorder and postorder traversal of a tree, construct the binary tree.
inorder:[9,3,15,20,7]
postorder:[9,15,7,20,3]
output :[3,9,20,null,null,15,7]
给定先序遍历和后序遍历的,求符合要求的二叉树。
//等优化后再来写
思路
本文标题:106 Construct Binary Tree from I
本文链接:https://www.haomeiwen.com/subject/zkgayqtx.html
网友评论