← 返回 meta 的题目列表Left and Right Side View of Binary Tree
类型:online_judge
Left and Right Side View of Binary Tree
Given a binary tree, output the sequence of node values visible from the left and right side views starting from the bottom left corner.
Requirements:
The sequence of nodes visible from the left and right views starts from the bottom left corner.
If a node is visible from both left and right views, it might need to be printed twice.
Example:
1
/ \
2 3
/
5
Output: [5, 2, 1, 3, 5]
Note: The last 5 might also be visible from the right view.
Constraints:
Number of nodes: [0, 100]
Each node has a unique value.
Example
Input
5
1 2 3 5 null