701. Top View of a Binary Tree
The top view of a binary tree refers to the set of nodes that are visible when the tree is viewed from the top. Given a binary tree, the task is to print its top view.
The input consists of a single line containing the level order traversal of the binary tree, represented as space-separated integers. In the level order traversal, -1 represents a null child, while any other value represents a node of the tree.
The output should be the space-separated values of the nodes that are visible from the top of the binary tree.
1 2 3 -1 -1 -1 -1
2 1 3
The number of nodes in the tree must be between 1 and 100,000 (inclusive).