Code RoomHeight balanced binary tree
MediumPrep Room Coding #125

Height balanced binary tree

CodingAlgorithms & data structuresMid–Senior~20 min

Given a binary tree as a level-order array `arr` (null for missing), return True if it is height-balanced — for every node, the heights of its two subtrees differ by at most 1 — and False otherwise. An empty tree is balanced. `0 <= node count <= 50000`.

Implement
is_balanced(arr: list[int]) → bool
Examples
in[[3,9,20,null,null,15,7]]outtrue
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 20 min
InputExpectedGot
[[3,9,20,null,null,15,7]]truenot run yetsample