Let's do this question.
Given the root of a binary tree.
Imagine yourself standing on the right side of it.
Return the values of the nodes you can see ordered from top to bottom.
So this is the first question.
The second question is given the root of a binary tree, imagine yourself standing on the left side
of it.
Return the values of the nodes you can see ordered from top to bottom.
So this is the same question.
Just in the first case, you're standing on the right side, and in the second case you're standing
on the left side.
So let's see how we can solve this.
And let's first try to understand the question.
Let's say this is the binary tree which is given to us.
And let's say we are standing on the right and we are looking at the binary tree in this direction.
So we can see these nodes.
Right.
We can see four, we can three, we can see three, seven, five and 12.
We cannot see one because it's blocked by this.
Three because these two are in the same level.
Similarly we cannot see two and eight because it is blocked by seven, because all these three are in
the same level.
And then we can see five and 12.
So this is the right side view of this binary tree.
So for question one the output should be an array with these values which is four, three, seven five
and 12.
Now for question two we are looking at this binary tree from the left side.
So that's in this direction.
So the nodes that we can see are these right.
So we can see 4125 and 12.
We cannot see three because it's blocked by one.
We cannot see eight and seven because it's blocked by two.
And we can see five and 12.
So the output array for question number two should be 4125 and 12.
So this is the question.
Now let's proceed and take a look at a few test cases.
Now let's say the binary tree which is given to us is having just one node.
So in this case even if we look from the right or from the left, we will just see that particular node.
So the output should be just an array with that particular value.
Right.
And if we are given a null null binary tree where the root itself is null in this case we will just
return an empty array.
And remember in the interview you have to come up with test cases together with your interviewer to
ensure that both of you are on the same page.
And then we have already discussed this case where this is the binary tree which is given to us.
Now, if you look from the right, you can see four, three, seven, five and 12.
So this is the output.
And if you look from the left you can see four one, two, five and 12.
So this is the output.
So this is the question.
And we have looked at a few test cases.
Now in the next video let's try to think how we can solve this question.