← ALL NOTES
Tree

102. Binary Tree Level Order Traversal

BFS with a queue walks a tree level by level naturally — the one thing you must add to group the output by level is snapshotting the queue's size at the start of each round. That size is exactly the…

Loading…