O35
Validate Binary Search Tree
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) -> boolInput & Output Contract
Output Rule:True veya False.
System Constraints
0 <= agac.length <= 10^4
-2^31 <= agac[i] <= 2^31 - 1Example 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 -> FalseExample Test Scenarios (3)
Example 1: Valid
Input:
[[2,1,3]]Expected Output:
trueExample 2: Invalid
Input:
[[5,1,4,null,null,3,6]]Expected Output:
falseExample 3: Eşit Değer (Kesin Küçük Olmalı)
Input:
[[1,1]]Expected Output:
false