Top View of a Binary Tree
Asked in the Logical and Maintainable Code stage. Given a binary tree, print the top view of the binary tree.
Represent each node as [value, left, right], where a missing child is null. The function receives the root representation and returns a list of visible node values from left to right. Use breadth-first traversal so shallower nodes are considered before deeper nodes. If a right child reaches an already occupied horizontal distance, include it after the regular top-view values in discovery order, as required by the grading contract.
def top_view(root):