Binary tree right side view and Lowest common ancestor
Consider a binary tree. If you look at it from the right-hand side, return a list of values of the nodes that are visible from the top to the bottom.
Example 1:
Input: [10, 5, 15, null, 7, null, 20]
Output: [10, 15, 20]
Explanation:
10 <---
/ \
5 15 <---
\ \
7 20 <---
Example 2:
Input: [3, 9, 8, 4, null, null, 7]
Output: [3, 8, 7]
Explanation:
3 <---
/ \
9 8 <---
/ \
4 7 <---