优化0106.从中序与后序遍历序列构造二叉树.mdJava解法
This commit is contained in:
parent
cae6b56b2d
commit
3450a85b6d
|
|
@ -607,6 +607,7 @@ class Solution {
|
||||||
for (int i = inLeft; i < inRight; i++) {
|
for (int i = inLeft; i < inRight; i++) {
|
||||||
if (inorder[i] == rootVal) {
|
if (inorder[i] == rootVal) {
|
||||||
rootIndex = i;
|
rootIndex = i;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 根据rootIndex划分左右子树
|
// 根据rootIndex划分左右子树
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue