Given n cities connected by flights with prices, along with a source, a destination, and a maximum number of stops k, return the cheapest price to travel from source to destination using at most k stops; return -1 if it's not possible.
n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1700Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Beyond basic traversal, some graph problems need ordering constraints (topological sort) or weighted shortest paths (Dijkstra, Bellman-Ford, minimum spanning trees).
Read the full Advanced Graphs guide →
Original problem on LeetCode ↗