Tree left view 2nd testcase

Can you please tell why my second testcase is not being passed? https://ide.codingblocks.com/s/109735

Hello @urvigoel26,

Your code is proding no or wrong output for the testcases like:

1 -1 2 -1 3 -1 4
Expected Output:
1 2 3 4
Your Output:
no output

1 6 2 8 7 4 3 11 -1 9 -1 5 -1 -1 -1 -1 -1 10 -1 -1 -1 -1 -1
Expected Output:
1 6 8 11 10
Your Output:
1 6 8 11

Explanantion:
Structure of trees formed:

_______1
___________2
_______________3
___________________4

______________________1
____________6_____________________2
_____8_____________7_______4_____________3
_11_____________9_______5
____________10

Hope, this would help.
Give a like, if you are satisfied.

2 Likes