给定两个整数数组 preorder
和 inorder
,其中 preorder
是二叉树的先序遍历, inorder
是同一棵树的中序遍历,请构造二叉树并返回其根节点。
示例 1:
输入: preorder = [3,9,20,15,7], inorder = [9,3,15,20,7] 输出: [3,9,20,null,null,15,7]
示例 2:
输入: preorder = [-1], inorder = [-1] 输出: [-1]<iframe allowfullscreen="true" data-mediaembed="bilibili" frameborder="0" id="5rl94PZo-1717120179950" src="https://player.bilibili.com/player.html?aid=112532172049152"></iframe>
Leetcode 105
(抖音号:708231408)
标签:preorder,遍历,20,中序,15,二叉树,708231408,inorder From: https://blog.csdn.net/gordenflfl/article/details/139342646