Dsa
Binary Search Tree
Easy
Validate BST Depths
Given a binary search tree represented by a list of inorder traversal values, determine if the tree is valid and calculate the maximum depth of the valid BST.
The input will be a list of integers, and the output should be the maximum depth of the BST if valid, or -1 if invalid.
Example Input:
[3, 1, 4, 2]
Example Output:
3
Key concepts
binary_search_treevalidationrecursion
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now