Dodomeki
Sign in

72. Right Side View

Medium

Return the values that would be seen when observing the tree from the right side, one per level, from the root downward. When a level has multiple nodes, use the last one from left to right.

Example 1
Input: raiz = [1, 2, 3, null, 5, null, 4]
Output: [1, 3, 4]
Example 2
Input: raiz = []
Output: []
Constraints
  • 0 <= quantidade de nós <= 10^4
TreesBFSQueue
Caso 1
raiz =
[1,2,3,null,5,null,4]
Expected =
[1,3,4]
Caso 2
raiz =
[]
Expected =
[]

Run checks these 2 cases. Submit runs all 7, including hidden ones.