one line python solution

  • 0
    class Solution(object):
        def isValidBST(self, root, mini=float('-inf'), maxi=float('inf')):
            :type root: TreeNode
            :rtype: bool
            return True if not root else \
                mini < root.val < maxi \
                and self.isValidBST(root.left, mini, root.val) \
                and self.isValidBST(root.right, root.val, maxi)

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.