优化0106.从中序与后序遍历序列构造二叉树.mdJava解法

This commit is contained in:
ironartisan
2021-09-06 11:32:18 +08:00
parent cae6b56b2d
commit 3450a85b6d

View File

@ -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划分左右子树