Breadth-First Search
Medium
Binary Tree Rightmost Node (Right Side View)
Return the values of the nodes you can see ordered from top to bottom.
10 min
Solve on LeetCodeProblem Understanding
Given the root of a binary tree, imagine yourself standing on the right side of it. Return the values of the nodes you can see ordered from top to bottom.
- Essentially: For every level, pick the last node.
Algorithm Strategy
We can use BFS (Level Order Traversal).
- Process the tree level by level.
- For each level, the last node in the queue (before moving to the next level) is the rightmost node.
- Add that node's value to our result list.
Interactive Visualization
Step 1 / 1
Empty Heap
Initializing...
1x
See the Logic in Motion
Stop memorizing code. Unlock the full interactive visualizer to master the logic step-by-step.ON THIS PAGE
- Problem Understanding
- Algorithm Strategy
- Interactive Visualization
- Dry Run
- Edge Cases & Common Mistakes
- Solution Code
- Complexity Analysis
Stop Guessing, Start Mastering.
Build the FAANG intuition. Master this pattern with optimized implementations, visual dry runs, and our curated collection of high-yield problems.
