Bottom Right View of Binary Tree Problem Statement
Your task is to identify and return the bottom right view of a given binary tree.
This involves viewing the binary tree from an angle of 45 degrees from the bottom right side.
Example:
Explanation:
In the above binary tree, nodes {4, 5, 6} are visible from the bottom right. Nodes ‘1’ and ‘3’ are hidden behind node ‘6’, and node ‘2’ is hidden behind node ‘5’.
Input:
The first line contains an integer 'T' denoting the number of test cases.
The first line of each test case contains elements of the tree in level order format, separated by a space, with '-1' representing null nodes.
Output:
For each test case, output the array of values of visible nodes, sorted in ascending order.
Each test case output should be in a new line.
Example:
Input:
1
2 3
4 -1 5 6
-1 7 -1 -1 -1 -1
-1 -1
Output:
[4, 5, 6]
Constraints:
- 1 <= T <= 100
- 1 <= N <= 3000
- -10^9 <= data <= 10^9 (data != -1)
Where 'N' is the number of nodes in the tree, and 'data' denotes the data within a tree node.
Time Limit: 1 sec
Note:
You do not need to print anything; this function is about implementing logic only.

AnswerBot
4mo
Identify and return the bottom right view of a given binary tree by viewing it from an angle of 45 degrees from the bottom right side.
Traverse the binary tree in a right-to-left manner and keep track ...read more
Help your peers!
Add answer anonymously...
Paytm Software Developer interview questions & answers
A Software Developer was asked 3mo agoQ. Given a sorted array of integers nums and an integer target, write a function to...read more
A Software Developer was asked 7mo agoQ. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
A Software Developer was asked 8mo agoQ. Given a binary tree, return the vertical order traversal of its nodes' values. (...read more
Popular interview questions of Software Developer
A Software Developer was asked 7mo agoQ1. Given a 2D grid map of '1's (land) and '0's (water), count the number of islands...read more
A Software Developer was asked 8mo agoQ2. Given a binary tree, return the vertical order traversal of its nodes' values. (...read more
A Software Developer was asked 9mo agoQ3. Given a graph and a source node, find the shortest path from the source to all o...read more
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

