Browse Curriculum
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
Watch BFS collecting the last element of every level.
ON THIS PAGE
- Problem Understanding
- Algorithm Strategy
- Interactive Visualization
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.
