Tree top view tree

getting cases wrong and output in sorted order

Hey @guptashubham210a you have to print the output in the sorted order of value in your code while you are printing it based on what node you reached first in level order . So instead of printing while traversing you can store all the values you get in the map(which you did) and then after traversing the tree you can print the values stored in the map . (The map will sort the nodes according to the value (left first , right last ) ) .

I am attaching the corrected code i have just added added 2 lines have a look at that


Hope it helps . If your doubt is resolved please mark it as resolved and rate me accordingly . :blush: