Problem Statement: https://www.hackerrank.com/challenges/jack-goes-to-rapture
One of the solutions is use modified Dijkstra's Algorithm.
Original:
For a vertex u,
Forall vertices v, instead of updating the distance by,
alt = distance(u) + weight(u, v)
if(alt < distance(v)) distance(v) = alt
Modified:
For a vertex u,
Forall vertices v, instead of updating the distance by,
alt = max(distance(u), weight(u, v))
if(alt < distance(v)) distance(v) = alt
I am not able to get the intuition behind alt = max(distance(u), weight(u, v)) which is the maximum weight of the edges in the shortest path.
Could someone explain the intuition behind the solution.