Binary Tree Level Order Traversal (LC #102) returns nodes grouped by level. Use BFS with a queue. For each level, record the current queue size, then pop exactly that many nodes, adding their children. This groups nodes by level. Runs in time and space where is maximum width. Binary Tree Right Side View (LC #199) is a variant: only keep the last node of each level. Binary Tree Zigzag (LC #103) alternates left-to-right and right-to-left. learn this BFS template.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/trees/binary-tree-level-order-traversal
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████████████████████████████████████████████████████████████████████████████████████