Binary Tree Right Side View
Medium
LC #199
bfsdfsNot attempted yet
Imagine standing to the right of a binary tree. Return the values you can see, from top to bottom: the rightmost node of each level.
Example 1
Input: root = [1, 2, 3, None, 5, None, 4]
Output: [1, 3, 4]
Example 2
Input: root = [1, 2, 3, 4]
Output: [1, 3, 4]
Level 3 only has 4, on the left, but you still see it.
Example 3
Input: root = []
Output: []
Constraints
- 0 ≤ number of nodes ≤ 2 · 10^4
- -10^5 ≤ Node.val ≤ 10^5