Binary Tree Right Side View
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.
Example 1
Input
root = [1,2,3,null,5,null,4]
Output
[1,3,4]
Explanation
Looking at the tree from the right side, the visible node at each level is:
1 → 3 → 4
Example 2
Input
root = [1,null,3]
Output
[1,3]
Explanation
There is only one node visible at each level:
1 → 3
Constraints
Hints:
Hint 1
Process the binary tree level by level and identify the last node at each level.
Hint 2
Using BFS, the last node removed from the queue at every level is the node visible from the right side.
Author & Technical Reviewer
Technically reviewed by: ExamAdda Technical Review Team
Technical Reviewers, ExamAdda
Software engineers at ExamAdda who check every article's definitions, complexity claims and code examples before and after publishing.
Published
Aug 19, 2026
Last updated
Aug 20, 2026
Content Verification Methodology
Definitions and complexity claims were checked against authoritative computer-science references. Code examples were compiled and tested with standard, boundary and edge-case inputs.
Expected Output