654. 最大二叉树





class Solution(object):
    def constructMaximumBinaryTree(self, nums):
        """
        :type nums: List[int]
        :rtype: TreeNode
        """
        if not nums:
            return
        rootval = max(nums)
        rootindex = nums.index(rootval)
        root = TreeNode(rootval)
        root.left = self.constructMaximumBinaryTree(nums[:rootindex])
        root.right = self.constructMaximumBinaryTree(nums[rootindex + 1:])
        return root

原文地址:https://www.cnblogs.com/panweiwei/p/13585945.html