What is the error in this code?

Hi @goyalvivek
u have build the tree only wrong… try to print the level order of tree… u would get to know…
I have corrected ur code https://ide.codingblocks.com/s/629864 its working fine and passing all test cases…

But this is how its shown how to create a tree in the videos

Can u show me the recursive method to create the tree instead of looping

u have to create tree according to input given only… rest try to dry run u will get better insight…

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.