EvalFrame Technical Mock Interviews & Coding Practice

Balanced Binary Tree

Easy · Binary Tree · Algorithm problem · all problems

Given a binary tree represented as an array in level-order, determine if it is height-balanced. A height-balanced binary tree is a binary tree in which the depth of the two subtrees of every node never differs by more than one. **Examples:** ```typescript isBalanced([3, 9, 20, null, null, 15, 7]) // true isBalanced([1, 2, 2, 3, 3, null, null, 4, 4]) // false isBalanced([]) // true ```

Solve It in the BrowserPractice Explaining It Out Loud

Optimal Approach

  • Time complexity: O(n)
  • Space complexity: O(h)

Post-order DFS calculates the height of each node from bottom up in O(n) total time.

Follow-Up Questions Interviewers Ask About Balanced Binary Tree

  • Why is bottom-up DFS preferable to top-down for checking tree balance?
    Top-down recalculates heights repeatedly resulting in O(n^2) worst case, whereas bottom-up calculates height once per node in O(n).

Practice the full problem with execution, tests, and AI code review in the interactive lab — then rehearse explaining your solution in a live voice mock interview.