Leetcode 787. Cheapest Flights Within K Stops
Find the minimum-cost route from src to dst in a directed weighted graph with the constraint of at most k stops (i.e., a bound on the path length), returning -1 if no such route exists. This is a shortest-path problem with a path-length constraint, often handled by level-limited BFS/Dijkstra or K+1 iterations of Bellman–Ford.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early October, 2026
A travel booking system needs to find the lowest-cost route between airports. You're given n cities connected by flights, where each flight [from, to, price] represents a direct route with its cost. Find the cheapest route from src to dst that uses at most k layovers (intermediate cities). If no such route exists, return -1. Note: A route with k layovers means visiting k intermediate cities, or equivalently, taking k+1 flights.
Late April, 2025
Hello Interview Premium
Your account is free and you can post anonymously if you choose.