Tree right view

whats wrong in this code , its giving all the nodes instead of right veiw

…someone reply pls

hello @mohitsharmakosi2001

the method that u are using to construct the tree is wrong.

use level order constrcution method

but this method is explained in vedio. Whats wrong here in this method?

look at the input format of the question, u are given level order not preorder

time complexity is same in both the methods?

yes…