You are given information about n cities connected by m flights. Each flight is represented as [fromi, toi, pricei]
indicating a direct flight from city fromi
to city toi
with a cost of pricei
.
You are also given three integers:
src
– the starting citydst
– the target cityk
– the maximum number of allowed stops (i.e., you can take at mostk + 1
flights)
Your goal is to find the cheapest price to travel from src
to dst
with at most k
stops. If such a route doesn't exist, return -1
.