Back to DSA
Binary Tree Right Side View
mediumPicture 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
1234567