I have been working only on this problem for the past 2 days. I must have already spent 10 hours or so. I have a working solution for all the examples but not for the real solution.
Long story short, I had decided to use a greedy algorithm and after I saw your reply I will now try with Dijkstra's algorithm.
Thank you so much!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.