98-Validate Binary Search Tree

题目:验证一个二叉树是否为二叉排序树

def isValidBST(root):
    inorder = inorder(root)
    return inorder == list(sorted(set(inorder)))
def inorder(root):
    if root is None:
        return []
    return inorder(root.left) + [root.val] +inorder(root.right)

注:

采用遍历二叉树的中序遍历,如果结果为排序,则说明该二叉树是二叉排序树

原文地址:https://www.cnblogs.com/kingshine007/p/11372974.html