Balanced Binary Tree
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given the root of a binary tree, return true if the tree is height-balanced and false otherwise.
A tree is height-balanced when, at **every** node, the heights of the left and right subtrees differ by at most one. The height of an empty subtree is 0. An empty tree is balanced.
Checking only the root is not enough: a tree whose two root subtrees have equal height can still be unbalanced deeper down. Target O(n) time.
Examples
Constraints
- 0 <= number of nodes <= 5000
- -10^4 <= Node.val <= 10^4
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.