mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-11-19 12:43:46 +00:00
Update 7. 重建二叉树.md
统一 img 标签的写法。
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@
|
||||
|
||||
设根在中序遍历中的下标为 inIndex,左子树的节点数 leftTreeSize = inIndex - inL。在前序遍历中,根后面紧跟着的 leftTreeSize 个值是左子树,剩下的是右子树,由此得到递归时左右子树在前序数组中的范围。用哈希表记录中序遍历中每个值的下标,找根的位置只需要 O(1),整体时间复杂度为 O(N)。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/60c4a44c-7829-4242-b3a1-26c3b513aaf0.gif" width="430px"> </div><br>
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/60c4a44c-7829-4242-b3a1-26c3b513aaf0.gif" width="430px"/> </div><br>
|
||||
|
||||
```java
|
||||
// 缓存中序遍历数组每个值对应的索引
|
||||
|
||||
Reference in New Issue
Block a user