# -*- coding:utf-8 -*- # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def reConstructBinaryTree(self, pre, tin): if not pre or not tin: return None root=TreeNode(pre.pop(0)) a=tin.index(root.val) root.left=self.reConstructBinaryTree(pre,tin[:a]) root.right=self.reConstructBinaryTree(pre,tin[a+1:]) return root
原文:https://www.cnblogs.com/cong3Z/p/12933254.html