Cheapest route with at most k stops
flights is a list of (from, to, price) one-way flights among cities numbered 0 to
n - 1. Write cheapest(n, flights, src, dst, k) that returns the cheapest price from
src to dst using at most k intermediate stops, or -1 if impossible.
cheapest(4, [(0, 1, 100), (1, 2, 100), (2, 0, 100), (1, 3, 600), (2, 3, 200)], 0, 3, 1) -> 700
cheapest(3, [(0, 1, 100), (1, 2, 100), (0, 2, 500)], 0, 2, 1) -> 200
cheapest(3, [(0, 1, 100), (1, 2, 100), (0, 2, 500)], 0, 2, 0) -> 500
Dijkstra does not respect the stop limit. Instead relax every edge k + 1 times from a
copy of the previous round's costs (Bellman-Ford, limited to k + 1 rounds).
def cheapest(n, flights, src, dst, k):
...