We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python-Offer/second/third/six.py
Line 88 in bc82c24
这里如果 right 是 [] 的话,会导致 preorder[-len(right):] 的值变成该 preorder 的副本,前序遍历和中序遍历长度不一致,显然是不合理的。
right
[]
preorder[-len(right):]
preorder
应该写成
root.right = construct_tree(preorder[index + 1:], right)
或者对这一段重新整理一下
index = inorder.index(preorder[0]) root = TreeNode(preorder[0]) root.left = construct_tree(preorder[1:index + 1], inorder[0:index]) root.right = construct_tree(preorder[index + 1:], inorder[index + 1:]) return root
The text was updated successfully, but these errors were encountered:
感谢意见,我再看一下,优化一下
Sorry, something went wrong.
No branches or pull requests
Python-Offer/second/third/six.py
Line 88 in bc82c24
这里如果
right
是[]
的话,会导致preorder[-len(right):]
的值变成该preorder
的副本,前序遍历和中序遍历长度不一致,显然是不合理的。应该写成
或者对这一段重新整理一下
The text was updated successfully, but these errors were encountered: