Right side view of Binary Tree
Asked in the Round 2 - Technical Round with Sigmoid stage.
Given the root of a binary tree, return the values of the nodes visible when the tree is viewed from the right side. The input tree is represented as nested dictionaries with keys val, left, and right; an empty tree is null.
Implement right_side_view(root). Return a list containing the rightmost value at each depth, ordered from the root level downward.
def right_side_view(root):