DiffPush Tier Binary Trees · Hard O(n) · O(n)
A fulfilment hub draws its storage map as a binary tree, and safety inspectors measure each floor's span by counting the gaps between its outermost occupied bays — phantom bays in between still count toward the span. The audit report must publish the widest floor ever measured across the whole warehouse.
Input: A binary tree as a level-order array (null marks a missing child).
Output: Return the maximum width — the largest count of node slots, including null gaps, between the leftmost and rightmost node of any level.
1 <= number of nodes <= 10^5-10^4 <= node value <= 10^4Input: {"tree":[1,3,2,5,3,null,9]}
Output: 4
The last level stretches from slot 0 (5) to slot 3 (9): 5, phantom, phantom, 9 — a span of 4.
Input: {"tree":[1,3,null,5,3]}
Output: 2
The deepest level holds only 5 and 3 side by side, so the widest span is 2.