1 testcase is not passing

My sample output and 5 tescases are correct and I’m unable to find the error in code : https://ide.codingblocks.com/s/655811

hi @mitrapranav0027_5d705c8b616e0add
Refer this -->

Can you tell what’s wrong in my code? since I have used a different logic to the one you shared. Its just 1 testcase that’s coming out wrong.

ur code is failing on this test cases-> 20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
expected o/p --> 5 10 4 14 25
ur o/p --> 5 10 4 22 25
now make a tree and try to find the ans… u will understand that ur ans is not correct and hence would have to modify ur approach…

I drew the tree and did a dry run for vertical print. The run output was coming out different from that. Please dry run it and check the code. Here’s the tree: https://imgur.com/a/0Hlya71

hi @mitrapranav0027_5d705c8b616e0add
according to input 10 and 14 are children of node 3…

@mitrapranav0027_5d705c8b616e0add
Is there anything else??

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.