Only one test case showing wrong answer

https://ide.codingblocks.com/s/260220.

hello @Aparna
consider this input->
1 2 3 -1 4 -1 5 -1 -1 -1 6 -1 7 -1 8 -1 -1

your output ->
2 1 3 5
correct output->
2 1 3 5 6 7 8

issue might be with ur build tree function.
check that

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.