← 返回 amazon 的题目列表Right Side View of Binary Tree Using BFS or DFS
类型:online_judge
amazon
Given a binary tree, return the values of the nodes visible from the right side.
Solve this using BFS or DFS. Input is a binary tree, and the output should be an integer array representing the visible nodes from the right side.
Example Input:
1
/ \
2 3
\ /
5 4
Example Output:
[1, 3, 4]
The depth of the tree does not exceed 1000, and node values range from [0, 100].
Example
Input
1
2 5
3 4