Deep Dive
Bellman-Ford with K stops
787. Cheapest Flights Within K Stops · Shortest paths · 69 of 78
1/11
At most 1 stop
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.