text function isValidBST(root): return isValid(root, -infinity, +infinity) function isValid(node, min, max): if node == null: return true if node.val <= min or node.val >= max: return false return isValid(node.left, min, node.val) and isValid(node.right, node.val, max) Time complexity: . Visit each node once. Space complexity: for the recursion stack.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/maang-interview-prep/trees-bst/validate-binary-search-tree-pseudocode
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████████████████████