View From the East
mediumA photographer stands due east of a tree-shaped apartment block at sunset. From that angle she sees exactly one window per floor — the rightmost room on each level; everything behind it is hidden.
Given the root of a binary tree, return the values visible from the right side, top floor to bottom.
Tests pass a level-order array; implement the core in _right_view on real nodes.
Example 1
in values = [1, 2, 3, null, 5, null, 4]
out [1, 3, 4]
Per level the rightmost nodes are 1, then 3, then 4 — the 5 hides behind 4.
Example 2
in values = [1, null, 3]
out [1, 3]
Example 3
in values = []
out []
Constraints
- · 0 <= number of nodes <= 100
- · -100 <= node value <= 100
solution.py● loading python…
test results
Hit ▶ Run to test your code against the visible cases.