Deep Dive

Bellman-Ford with K stops

787. Cheapest Flights Within K Stops · Shortest paths · 69 of 78

1/11

At most 1 stop

100450100600200A∞Src0Dst∞B∞
In this lessonStep 1 of 11 · ← → keys
The question

Flights have prices. Find the cheapest way from Src to Dst using at most K stops. Plain Dijkstra fails here, because the cheapest path may use too many stops. Bellman-Ford with rounds counts the flights for us.