My code is not working for right view, not able to understand what is wrong in my code

hello @harshulgarg21
ur logic for right view is correct.
the issue is in ur buildtree function.

u r given a level order traversal . and then u need to construct tree from that.
change ur buildtrr function

image


here is the revised code but it is still not working

image

it should be ==


I have rectified my above mistake, bit still there is some declaration error coming

remove argument of buldtree function
and delcare root inside function only.

ur updated code–>

output should be 1,3,5,9,11 but I am not getting this output, in the above code

it is correct, i have submitted the code and it is working fine