Validate Binary Search Tree Visualizer & Solution | Rulcode
Loading problem details...
131. Validate Binary Search Tree
PRO
Medium
Topics
Companies
Hint
Understand Before Coding
Loading visualization...
Visualize This Problem
Open Visualizer
Draw Your Approach
Draw
Example 1:
Input:root = [2,1,3]
Output:true
Explanation:The tree is a valid BST because 1 < 2 < 3.
Example 2:
Input:root = [5,1,4,null,null,3,6]
Output:false
Explanation:The tree is not a valid BST because the node with value 4 has a left child with value 3, which violates the BST property (3 should be less than 4).
Constraints:
•
•
Time Complexity
O(n)
Space Complexity
O(h)
Step 1 / 60
Speed: 1.0x
Initialize BST validation for the root node 5 with range (-Infinity, Infinity).