Is it a search tree?
Write is_search_tree(root): return True if the binary tree is a valid binary search tree. That means that, for every node, all the values in its left subtree are strictly smaller than the node's value and all the values in its right subtree are strictly larger. Equal values are not allowed, and an empty tree is valid. Each TreeNode has val, left and right.
The tests call the provided run_is_search_tree(values), where values lists the tree level by level with null for a missing child: [1, null, 2, 3] is a root 1 with only a right child 2, whose left child is 3.
Examples
run_is_search_tree([8,3,10])→truerun_is_search_tree([8,3,10,null,null,2,12])→falserun_is_search_tree([5,5])→false