Update 面试总结.md

This commit is contained in:
孙海洲 2018-09-26 19:51:22 +08:00 committed by GitHub
parent 25d27ddaca
commit 99591d3adb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -470,15 +470,15 @@ private TreeNode reConstructBinaryTree(int[] pre, int preL, int preR, int inL) {
```python ```python
# 返回构造的TreeNode根节点 # 返回构造的TreeNode根节点
def reConstructBinaryTree(self, pre, tin): def reConstructBinaryTree(self, pre, tin):
# write code here # write code here
if not pre or not tin: if not pre or not tin:
return None return None
root = TreeNode(pre.pop(0)) root = TreeNode(pre.pop(0))
index = tin.index(root.val) index = tin.index(root.val)
root.left = self.reConstructBinaryTree(pre, tin[:index]) root.left = self.reConstructBinaryTree(pre, tin[:index])
root.right = self.reConstructBinaryTree(pre, tin[index + 1:]) root.right = self.reConstructBinaryTree(pre, tin[index + 1:])
return root return root
``` ```
# 8. 二叉树的下一个结点 # 8. 二叉树的下一个结点