Right Side View

Problem

Intution

If we carefully observe the above picture, we can understand that, the right view of binary tree is the right most node or last node at every level

Perform regular BFS traversal and update the list only if the current element that is being processed is the last element in the level

Time Complexity

O(V+E) -> Standard BFS time complexity

Space Complexity

O(1)

Auxillary space complexity

Code

Last updated