O35

Validate Binary Search Tree

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: BOOLEAN

Problem Statement & Objective

Given the root of a binary tree, determine if it is a valid binary search tree (BST).

Function Signature (Python)

validate_binary_search_tree(root: list) -> bool

Input & Output Contract

Output Rule:True veya False.

System Constraints

0 <= agac.length <= 10^4
-2^31 <= agac[i] <= 2^31 - 1

Example Execution Walkthrough

agac = [2, 1, 3] -> 1 < 2 < 3 -> True
agac = [5, 1, 4, None, None, 3, 6] -> 4'ün solundaki 3, kök 5'ten küçük olamaz -> False

Example Test Scenarios (3)

Example 1: Valid
Input:[[2,1,3]]
Expected Output:true
Example 2: Invalid
Input:[[5,1,4,null,null,3,6]]
Expected Output:false
Example 3: Eşit Değer (Kesin Küçük Olmalı)
Input:[[1,1]]
Expected Output:false
Loading Python Editor...
Input Parameters
[
  [
    2,
    1,
    3
  ]
]
Expected Output
true