Python


  • 0
    X

    class Solution:
    def sort(self,root):
    if root is None:
    return []
    nums = self.sort(root.left)
    nums.append(root.val)
    nums.extend(self.sort(root.right))
    return nums
    def isValidBST(self, root):
    """
    :type root: TreeNode
    :rtype: bool
    """
    list = self.sort(root)
    for i in range(len(list) - 1):
    if list[i] >= list[i+1]:
    return False
    return True


Log in to reply
 

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