mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-02 02:24:24 +00:00
build
This commit is contained in:
@@ -6,7 +6,7 @@ comments: true
|
||||
|
||||
!!! question
|
||||
|
||||
给定一个二叉树的前序遍历 `preorder` 和中序遍历 `inorder` ,请从中构建二叉树,返回二叉树的根节点。
|
||||
给定一个二叉树的前序遍历 `preorder` 和中序遍历 `inorder` ,请从中构建二叉树,返回二叉树的根节点。假设二叉树中没有值重复的节点。
|
||||
|
||||

|
||||
|
||||
@@ -54,10 +54,10 @@ comments: true
|
||||
<div class="center-table" markdown>
|
||||
|
||||
| | 根节点在 `preorder` 中的索引 | 子树在 `inorder` 中的索引区间 |
|
||||
| ------ | -------------------------------- | ----------------------------- |
|
||||
| 当前树 | $i$ | $[l, r]$ |
|
||||
| 左子树 | $i + 1$ | $[l, m-1]$ |
|
||||
| 右子树 | $i + 1 + (m - l)$ | $[m+1, r]$ |
|
||||
| ------ | ---------------------------- | ----------------------------- |
|
||||
| 当前树 | $i$ | $[l, r]$ |
|
||||
| 左子树 | $i + 1$ | $[l, m-1]$ |
|
||||
| 右子树 | $i + 1 + (m - l)$ | $[m+1, r]$ |
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user