Given the root of a binary tree, imagine standing on its right side. Return the values of the nodes visible from the right, ordered top to bottom.
Input: root = [1,2,3,null,5,null,4]
Output: [1,3,4]
Topics: trees
Asked by: Amazon, Meta, Microsoft, Google
Time complexity: O(n). Space complexity: O(n).