Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree.
Example 1:
Input:
2
/ \
1 3
Output:
1Example 2:
Input:
1
/ \
2 3
/ / \
4 5 6
/
7
Output:
7Note:You may assume the tree (i.e., the given root node) is notNULL.
分析
bfs就是层遍历,注意每次弹出的是q[0]
DFS
哪个先突破新高度就是那个node,每次都是左边先
Last updated
Was this helpful?