diff --git a/notes/面试总结.md b/notes/面试总结.md index c83951f4..a03e93d3 100644 --- a/notes/面试总结.md +++ b/notes/面试总结.md @@ -475,15 +475,15 @@ private TreeNode reConstructBinaryTree(int[] pre, int preL, int preR, int inL) { ```python # 返回构造的TreeNode根节点 - def reConstructBinaryTree(self, pre, tin): - # write code here - if not pre or not tin: - return None - root = TreeNode(pre.pop(0)) - index = tin.index(root.val) - root.left = self.reConstructBinaryTree(pre, tin[:index]) - root.right = self.reConstructBinaryTree(pre, tin[index + 1:]) - return root +def reConstructBinaryTree(self, pre, tin): + # write code here + if not pre or not tin: + return None + root = TreeNode(pre.pop(0)) + index = tin.index(root.val) + root.left = self.reConstructBinaryTree(pre, tin[:index]) + root.right = self.reConstructBinaryTree(pre, tin[index + 1:]) + return root ``` # 8. 二叉树的下一个结点