Dsa
Trees
Medium
Balanced Tree Height Difference
Given a binary tree, determine if it is balanced. A balanced tree is defined as one where the height of the two child subtrees of any node never differ by more than one. Print '1' for true and '0' for false.
Input format:
The input consists of a string that represents a binary tree in level order (e.g., '3,9,20,null,null,15,7').
Output format:
Print '1' if the tree is balanced, otherwise print '0'.
Example:
Input:
3,9,20,null,null,15,7
Output:
1
Key concepts
treesbalanceheight
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