Problem
You get the root root of a binary tree. In a binary tree, each node has at most two children: a left child and a right child.
A level of the tree is the group of nodes at the same distance from the root. Think of a person who stands on the right side of the tree. On each level, this person sees only the rightmost node.
Return the values of the nodes that the person sees, from the top level to the bottom level. For an empty tree, return an empty list.
The examples show each tree as a list in level order. This list gives the nodes row by row, from left to right. The value null marks a missing child.
Example 1
- Input:
- root = [8,4,12,2,6]
- Output:
- [8,12,6]
- Explanation:
- On the third level,
6is the rightmost node. The person sees it, although its parent4is on the left side.
Example 2
- Input:
- root = [7,3,null,1]
- Output:
- [7,3,1]
- Explanation:
- Each level has only one node, so the person sees all the nodes.
Example 3
- Input:
- root = []
- Output:
- []
Constraints
- 0 <= number of nodes <= 100
- -100 <= Node.val <= 100
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Find the Left and Right Side View of a Binary Search Tree
Coding
- Binary Tree Zigzag Side View
Coding
- Find Nearest Right Node in Binary Tree
Coding
- All Nodes Distance K in Binary Tree
Coding · Binary Tree · Breadth-First Search · Depth-First Search
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Meta
Leetcode 199. Binary Tree Right Side View
Reported Apr 15, 2026 · 48 source reports
JUNIOR, MANAGER, MID_LEVEL, SENIOR, STAFF
Source snapshot: Nov 12, 2026
View source