Tree BFS
LC #199Medium
Binary Tree Right Side View
Tree BFS
AmazonGoogleMetaBloombergProblem
Return the values of the nodes you can see from the right side of the tree (rightmost node per level).
treebfsdfs
Constraints
- ›0 ≤ n ≤ 100
- ›-100 ≤ Node.val ≤ 100
Example
Input
root = [1, 2, 3, null, 5, null, 4]Output
[1, 3, 4]Why
Rightmost node per level: 1 (L0), 3 (L1), 4 (L2)