Vertical traversal


Only one test case is passing.I stored nodes with horizontal distances in a map while constructing the tree in level order traversal.

see for test case like:
15 10 20 5 12 18 25 4 7 11 14 16 19 22 29 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
ans should be

7 
12 
20 11 14 19 
10 18 25 
16 5 22 29 
4 

you re getting wrong
also print the answer in 1 single line as in output file all output are in same line
so 7 12 20 11 14 19 10 18 25 16 5 22 29 4

1 Like

Thanks i got it with preorder traversal.