Daily challenge for 2026-01-24
389. Find Root of Binary Tree
Given the root of a binary tree, determine if it is a valid Binary Search Tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees must also be binary search trees. Assume the input tree structure uses nodes with val, left, and right attributes. Return true if it is a valid BST, and false otherwise. The input will be the root node object or null if the tree is empty.
Example:Input: {"val":2,"left":{"val":1,"left":null,"right":null},"right":{"val":3,"left":null,"right":null}}Output: True
Run this challenge interactively in Python or JavaScript when the app loads.