Dsa
Binary Search Tree
Medium
Find Maximum Depth of BST
Given a binary search tree (BST), find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
Input Format:
- The first line contains an integer n, the number of nodes in the BST.
- The next n lines each contain a single integer x, denoting the value of a node.
Output Format:
- Output the maximum depth of the BST.
Example:
Input:
5
3
1
4
6
5
Output:
3
Key concepts
binary_search_treedepthtraversal
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