Right view of binary tree

I’m getting a complete different answer. can you please modify it.

hi @dips123deepali_c25f140838182212
refer this -->

what is wrong with my code

@dips123deepali_c25f140838182212
there was error in ur for loop of right view function… first left root will be pushed in then the right one… u had written vice versa…
corrected code -->


It’s working fine…

Thank you so much .I’m getting the right answer now.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

I have one last doubt why are we pushing left child first for right view

bcoz we want to print right leaf nodes… hence we push nodes from left to right order…