Coding

Validate if a given tree is a valid binary search tree.

Given the root of a binary tree, determine if it is a valid binary search tree (BST). A valid BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key, and the right subtree contains only nodes with keys greater than the node's key.

Input: root = [5,1,4,null,null,3,6]

Output: FALSE

Explanation: Node 4 is in the right subtree of Node 5, but 4 is less than 5, which violates the BST property.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions