From 99591d3adb6e792dd45d475a6ea8182d7cbf2711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=B5=B7=E6=B4=B2?= Date: Wed, 26 Sep 2018 19:51:22 +0800 Subject: [PATCH] =?UTF-8?q?Update=20=E9=9D=A2=E8=AF=95=E6=80=BB=E7=BB=93.m?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/面试总结.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/notes/面试总结.md b/notes/面试总结.md index a6704fbe..9e583e92 100644 --- a/notes/面试总结.md +++ b/notes/面试总结.md @@ -470,15 +470,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. 二叉树的下一个结点