Optimal Algorithmic Approach
BFS with level-size tracking.
Core Invariants & Edge Cases
- Enqueue the root; while queue non-empty process all nodes of current level
- Record size of queue at start of each level to know level boundary
- Collect results per level into a list of lists