Skip to main content

Validate Binary Search Tree

MediumPremium

Determine if a given binary tree is a valid Binary Search Tree (BST).

Examples

All trees defined in level-order root = [5, 2, 6] output: true root = [5, 2, 4, null, null, 3, 6] output: false root = [] output: true

In these examples, the output is true if the given binary tree root is a valid BST, and false otherwise.