Medium
,DP
,DFS
,BFS
,Graph
,Heap
787. Cheapest Flights Within K Stops
There are n
cities connected by some number of flights. You are given an array flights
where flights[i]
= [, , ] indicates that there is a flight from city to city with cost .
You are also given three integers src
, dst
, and k
, return the cheapest price from src
to dst
with at most k
stops. If there is no such route, return -1
.
Example 1:
Example 2:
Example 3:
Constraints:
flights.length
<= (n * (n - 1) / 2)
flights[i].length
== 3n
src
, dst
, k
< n
src
!= dst
Yen-Chi ChenThu, Jan 26, 2023
DanTomorrow is Monday, happy working, Jan 29, 2023