Mental Model
We want to find the widest level in a tree by counting nodes between the leftmost and rightmost nodes at each level, including gaps.
Analogy: Imagine a tree as a family photo where some people stand far apart. The width is the distance between the leftmost and rightmost person in each row, counting empty spaces too.
1
/ \
3 2
/ \
5 9
/ \
6 7
Levels:
Level 0: 1
Level 1: 3 -> 2
Level 2: 5 -> null -> null -> 9
Level 3: 6 -> null -> null -> null -> null -> null -> null -> 7