Pattern Recognition Drill
Medium Trees
The Problem
Given a binary tree, return the values visible from the right side (rightmost node at each level).
What approach would you use?
Think about it before scrolling down.
Level-order traversal. Append the last node of each level to result. O(n).
DFS going right first. Track level; if level == len(result), append value. O(n).
Common Trap
DFS right-first works but BFS is more intuitive. Don't assume it's just the rightmost branch.