Given the root of a binary tree, imagine standing on the right side of it.
Return the values of the nodes you can see from top to bottom.
For the Cheetcode runner, trees are represented as level-order arrays with null placeholders for missing children.
Reason about the value returned from each subtree and the state passed down from ancestors. Empty children and single-node trees should be handled naturally.
Examples
Input: root = [1,2,3,null,5,null,4] Output: [1,3,4]
Input: root = [1,null,3] Output: [1,3]
Constraints
- The number of nodes in the tree is in the range [0, 100].
- -100 <= Node.val <= 100