165. Cheapest Flights Within K Stops

Given n cities, flights flights as [from, to, price], cities src, dst, and a stop limit k. Return the cheapest price from src to dst with at most k stops, or -1.
Example 1
Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0
Output: 500
Explanation: No stopovers — direct flight only.
Example 2
Input: n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1
Output: 200
Explanation: With one stopover it's cheaper than direct.
graph
JavaScript
Loading...
Line 1, Char 1