giving wrong ans in 1 test case
I have applied the concept of vertical order print and modified it to give the last element in the vector as only that will be seen from bottom.However one test case is still failing
code:https://ide.codingblocks.com/s/265319
Where is it failing
@bhaskar0_0 you are storing your nodes in map and printing last value of every index,but in some cases you map is not storing the leaf in last and hence giving wrong answer,
for ex look at this case : 20 8 22 5 3 4 25 -1 -1 10 14 -1 -1 -1 -1 -1 -1 -1 -1
so the vertical order print is also wrong in this case?
what will be the correct method to find vop in this case
use level along with the distance of nodes. i have updated your vop function look at this https://ide.codingblocks.com/s/265419
Can you please explain line 50.the if condition btw thanks for your help
we store nodes in map only if we go to that distance first time or if a node at that distance is already visited then we update map with node at higher level.
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.