← 返回 apple 的题目列表Cheapest Flights Within K Stops
类型:qbank
There are n cities connected by some flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates a flight from city fromi to city toi with cost pricei.
Examples
Example 1:
Input: n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1
Output: 700
Example 2:
Input: n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 2
Output: 400
Constraints
1 <= n <= 100
0 <= flights.length <= n * (n - 1) / 2
flights[i].length == 3
0 <= from_i, to_i < n
1 <= price_i <= 10^4
0 <= k < n