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.

Community Answers

1 answer from the community

Unlock Full Access

Answer any un-answered question from our database to unlock all community answers for 30 days.

Give & Take

Practice More Questions

2 answers published. Last candidate submission on Sep 20 2026, 6:34pm PDT. Interview question asked to Software Engineers interviewing at ZocDoc, Alan, Sift and other companies. Original question asked: Validate if a given tree is a valid binary search tree.. Question last reported by a candidate interviewing at Amphenol for a Software Engineer interview on Sep 28 2026, 6:08am PDT.