Is It a Search Tree?
Medium · Is It a Search Tree?
You are given the `root` of a binary tree. Check whether it is a binary search tree. A tree is a search tree when, for every node, all values in its left subtree are strictly smaller than the node's value and all values in its right subtree are strictly larger. Note that a node must be compared with all of its descendants, not just its direct children. Return `True` if the tree is a search tree and `False` otherwise.…
Solve the problem →