Approach Summary
BFS level-order: take the last node of each level. Or DFS right-first: record the first node seen at each depth.
How to Recognize This Pattern
- "What you see looking from the right"
- Last node in each BFS level OR right-first DFS
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(n)
Tags
Tree DFS BFS Binary Tree