LeetCode 98 Validate Binary Search Tree - Problem Statement

The problem

Given the root of a binary tree, determine if it's a valid Binary Search Tree (BST).

A valid BST has these properties:

  • Every node in the left subtree has a value less than the node's value.
  • Every node in the right subtree has a value greater than the node's value.
  • Both subtrees are also valid BSTs.

This tree is valid:

  2
 / \
1   3

This tree is NOT valid (5 > 4 but 5 is in the right subtree of 4):

    5
   / \
  1   4
     / \
    3   6

Constraints: 11 \le nodes 104\le 10^4.