Zerodha Portfolio Balanced Tree Check
Zerodha Portfolio Balanced Tree Check
MediumTrees100% accepted
Zerodha internal risk engine uses a height-balanced binary tree to store stock data for O(log n) access. Given the root of a binary tree, determine if it is height-balanced: for every node the height difference between its left and right subtrees is at most 1.
Approach
Check if a binary tree is height-balanced.
Input
7
3 9 20 -1 -1 15 7
Output
true
More Trees problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards