I guess the problem is that I’m not able to save the shortest path from each wormwhole and I don’t know how to fix that.
code-https://ide.codingblocks.com/s/325984
My code doesn't work for all test cases
Hi Aman,
Can you elaborate more?
When I put input for 1 wormhole it words but when i add more paths it doesn’t. I guess its because maybe I’m not able to take a path from one wormhole to another instead it just uses one wormhole at a time and I can’t figure how to do that.
Aman make findans function’s return type as int which returns minimum time traversal for starting position as (sx,sy).
also inside loop don’t update sx and sy(you did in line number 21,22) and don’t use a global variable ans.
Try making these changes!
See that N<=5, also using a warmhole twice is of no use, so you can try every possibility (every permutation & combination).
I did the updates but still don’t get the right answer.
Aman refer this one, easy to understand + commented
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.