Right Side View of a Binary Tree
Difficulty: Medium · Pattern: Tree BFS · Concept: Algorithms & Data Structures — Core Data Structures
Level-Order Traversal flattened an entire tree into one list, level by level. This variant needs BFS to be level-aware, not just level-ordered: imagine standing to the right of the tree — what's the sequence of nodes actually visible? For each level, that's exactly the last node BFS would visit at that depth, and the plain flat-queue approach from Level-Order Traversal has no notion of "where one level ends and the next begins" to make that possible.
Your task: implement right_side_view(root), returning a list of one value per level (the rightmost node's value), top to bottom.
More problems are being added continuously — see Practice Problems overview for the full, current list.