Tree bottom view

it is failing one testcase.
code-https://ide.codingblocks.com/s/157737

20 8 22 7 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1 with this input it is giving one wrong node. its giving 7 10 4 22 25 but ans should be 7 10 4 14 25 . can u plz tell me the mistake

yes there is a misatke
build the tree u will see
vertically 22 comes after 14 so ur code will replace 14 by 22

but horizontally 14 is lower than the 22 so as 14 and 22 is on same verticall line 14 is more deeper so by looking at bottom u will see 14 not 22

u can refer this

i have understood the mistake. but how to rectify it in the code i have sent?

see my code attached below
check the function bottom view
i just use a map in which i have key as vertically dist
and a pair which contain value and the horizontal dist
so just before updating the key i check whether the horizontal dist of my current k is greater or not

i have seen your code. can u plz suggest me correction im my code(code which i attached in beginning)?

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.