106 Construct Binary Tree from I

2019-02-26  本文已影响0人  烟雨醉尘缘

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

//等优化后再来写
踩过的坑:

  思路

时间复杂度O(n^2)
空间复杂度O(1)

上一篇 下一篇

猜你喜欢

热点阅读