LeetCode p199 Binary Tree Right Side View 题解
1.题目:
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.
For example:
Given the following binary tree,
1 <—
/ \
2 3 <—
\ \
5 4 <—
题意:
给你一个二叉树,返回它从右边看过去是一个什么样的列表。【从上往下排列】
2.解题思路:
见代码
搜索最右。
3.代码
1 |
|