Dsa
Binary Search Tree
Hard
Balanced BST Height Checker
Given the root of a binary search tree, write a program to determine if the tree is height-balanced or not. A height-balanced binary tree is a tree in which the depth of the two subtrees of every node never differs by more than one. The input format is:
First line: an integer N, the number of nodes in the BST.
Next N lines: each line contains unique integer values representing the nodes of the BST.
Output 'YES' if the tree is height-balanced, otherwise 'NO'.
Example:
Input:
4
3
1
2
5
Output:
NO
Key concepts
binary_search_treebalanceheight
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