Bellman-ford

2 articles

dsa9 min read

Cheapest Flights Within K Stops — Bellman-Ford with a Twist

LC 787 Cheapest Flights Within K Stops asks for the cheapest route from src to dst using at most k intermediate stops. Bellman-Ford with exactly k+1 relaxation rounds handles the stop constraint cleanly without Dijkstra getting confused by the layered state.

Read →