Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to construct a graph out of highways. What type of graph is this?
We essentially need to find the minimum distance to get from node 0 to node n - 1 in an undirected weighted graph. What algorithm should we use to do this?
Use Dijkstra's algorithm to find the minimum weight path. Keep track of the minimum distance to each vertex with d discounts left