dsa · easy

Validate Binary Search Tree

GreyOrangeTreeRecursionFoundation

Return whether the tree is a BST (strict: left < node < right for the whole subtree).

Arguments

**Example**

`` Input: [2,[1,None,None],[3,None,None]] Output: True ``

Constraints

Number of nodes in [0, 10^4] Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[2,[1,None,None],[3,None,None]]

Expected:
true

Example 2

Input:
[5,[1,None,None],[4,[3,None,None],[6,None,None]]]

Expected:
false

Open in the Dojo editor