# 返回构造的TreeNode根节点 def re_construct_binary_tree(pre, tin): if not pre or not tin: return None root = TreeNode(pre.pop()) index = tin.index(root.val) root.left = self.reConstructBinaryTree(pre, tin[:index]) root.right = self.reConstructBinaryTree(pre, tin[index + 1:]) return root
原文:https://www.cnblogs.com/rnanprince/p/11588434.html