Please enter your email address or userHandle.
Given a Binary Tree, find Right view of it. Right view of a Binary Tree is set of nodes visible when tree is viewed from right side.
Right view of following tree is 1 3 7 8.
/ \ / \
4 5 6 7
Output: 1 2
Output: 10 30 60
Just complete the function rightView() that takes node as parameter and returns the right view as a list.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(Height of the Tree).
1 <= Number of nodes <= 105
1 <= Data of a node <= 105.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.