731. Right Side View
0
Medium
Given a binary tree, output the right side view of the tree in top-to-bottom order. The right side view consists of the nodes that are visible when standing to the right of the tree.
Input Format
The input consists of a level order traversal of the binary tree. Each node is represented by a value, and a -1 represents a null child.
Output Format
Print the right side view as a space-separated list of integers in top-to-bottom order.
Example
Input
1 2 3 -1 -1 -1 -1
Output
1 3
Constraints
1<=number of nodes in the binary tree <=10^5
Loading...
View Submissions
Console