199. Binary Tree Right Side View

Practice Binary Tree Right Side View for free on NudgeCode: Medium, Binary Tree pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Imagine standing to the right of a binary tree. Return the values you can see, from top to bottom: the rightmost node on each level.

Example

root = [1,2,3,null,5,null,4]  ->  [1,3,4]
root = [1,2,3,4]              ->  [1,3,4]

Constraints