105. Construct Binary Tree from Preorder and Inorder Traversal

从中序遍历和前向遍历得到一个 preorder = [3,9,20,15,7] inorder = [9,3,15,20,7] Return the following binary tree: 解析 查找在inorder 中根节点的index, 然后求出 左边子树的长度 为 int leftsize = index - s2 六个位置关系 preorder[ ] = [ s1, s1+1 , s
相关文章
相关标签/搜索