Back to DSA

Binary Tree Right Side View

medium
Acceptance: 52%
Binary Tree

Picture yourself looking at a binary tree from the right side. Report the node values you would see at each depth level, ordered from the top of the tree to the bottom.

Examples

Example 1:
Input:root = [1,2,3,4,null,null,5]
Output:[1,3,5]
Example 2:
Input:root = [8,null,6]
Output:[8,6]

Hints

00:00
1234567