Trees: Is This a Binary Search Tree?

  • + 0 comments

    Single line solution

    def checkBST(root, min_v =-1 , max_v = 10001):
        return True if root is None else (root.data < max_v and root.data > min_v  and checkBST(root.left, min_v, root.data) and checkBST(root.right,root.data, max_v))