Pattern
Use BFS and track the first or last node at each level. That gives you left or right view in one pass.
Variation
Use DFS with depth tracking, but ensure you visit left or right first depending on the view you want.
Use BFS and track the first or last node at each level. That gives you left or right view in one pass.
Use DFS with depth tracking, but ensure you visit left or right first depending on the view you want.