Level: [New Grad]
Education: [Undergrad]
Years of Experience: [0]
Questions Asked: [Binary tree right side view]
Example 1:
2.Input: root = [1,2,3,null,5,null,4]*
3.Output: [1,3,4]*
4.Explanation: traversing the binary tree, we can see that each most right node at every level can be found by simply going right. in this case we “ignore” 2 as the 3 is further right on the same level*
Example 2:
5.Input: root = [1,2,3,4,null,null,null,5]*
6.Output: [1,3,4,5]*
7.Explanation: after traversing the first level of the binary tree, we can see we can no longer move right, however this does not mean there arent more nodes that would qualify as “right most” node. In this case, there are two nodes on the left branch that would still be seen in a right side view, thus we traverse left and return 4 and 5*