0105. 从前序与中序遍历序列构造二叉树 #223
Replies: 1 comment 1 reply
-
这里的时间复杂度,感觉是 O(n^2)呀,不过可以使用哈希表在 inorder 中寻找 k,可以降到 O(N) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
0105. 从前序与中序遍历序列构造二叉树
--- 0105. 从前序与中序遍历序列构造二叉树 标签:树、数组、哈希表、分治、二叉树 难度:中等 题目链接 0105. 从前序与中序遍历序列构造二叉树 - 力扣 题目大意 描述:给定一棵二叉树的前序遍历结果 preorder 和中序遍历结果 inorder。 要求:构造出该二叉树并返回其根节点。 说明: 1≤preorder.length≤3000...
https://algo.itcharge.cn/solutions/0100-0199/construct-binary-tree-from-preorder-and-inorder-traversal/
Beta Was this translation helpful? Give feedback.
All reactions