The input is the root of a binary tree. Return the values of the nodes you can see when looking from the right side, ordered from top to bottom. Google interviewers use tree traversal problems like this to test your BFS and level-order thinking.
For example, given [1,2,3,null,5,null,4], you'd return [1,3,4]. Node hides node at level , and node hides node at level .
Before moving on, think about this: you need the rightmost node at every level. What traversal gives you access to all nodes at the same depth?
Constraints: , node values from to .