Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Binary Tree Right Side View
Bookmark
BFS
DFS
Input
Example 1
Example 2
Complete Tree
Left Skewed
Custom
tree
=
[1, 2, 3, null, 5, null, 4]
1
2
3
5
4
L0
L1
L2
view
queue
result
keep the last node of every level
1
2
3
5
4
L0
L1
L2
view
queue
result
keep the last node of every level
1
2
3
5
4
L0
L1
L2
view
queue
result
rightmost =
1
1
2
3
5
4
L0
L1
L2
view
queue
2
front
result
found right child
3
1
2
3
5
4
L0
L1
L2
view
queue
2
3
front
result
1
result = [
1
]
1
2
3
5
4
L0
L1
L2
view
queue
3
front
result
1
rightmost =
2
1
2
3
5
4
L0
L1
L2
view
queue
5
front
result
1
rightmost =
3
1
2
3
5
4
L0
L1
L2
view
queue
5
4
front
result
1
visible from the right:
3
1
2
3
5
4
L0
L1
L2
view
queue
5
4
front
result
1
3
level 2:
2 nodes
1
2
3
5
4
L0
L1
L2
view
queue
result
1
3
visible from the right:
4
1
2
3
5
4
L0
L1
L2
view
queue
result
1
3
4
return [1, 3, 4]
algo
master
.
io
Step:
Start: find the right side view of the binary tree
0 / 27
Input
Example 1
Example 2
Complete Tree
Left Skewed
Custom
tree
=
[1, 2, 3, null, 5, null, 4]
0 / 27
algo
master
.
io
Step:
Start: find the right side view of the binary tree