Medium · Trees
Print side view
Given the root of a binary tree, return the values of the nodes you can see standing on its right side, ordered from top to bottom (the rightmost node of each level).
Examples
Example 1
[1,2,3,null,5,null,4]Output: [1, 3, 4]
Example 2
[1,2,3,4,5]Output: [1, 3, 5]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.