leetcode-787-Cheapest Flights Within K Stops
问题
There are n cities connected by m flights. Each flight starts from city uand arrives at v with a price w.
Now given all the cities and flights, together with starting city src and the destination dst, your task is to find the cheapest price from src to dst with up to k stops. If there is no such route, output -1.
1 | Example 1: |
Note:
- The number of nodes
nwill be in range[1, 100], with nodes labeled from0ton`` - 1. - The size of
flightswill be in range[0, n * (n - 1) / 2]. - The format of each flight will be
(src, ``dst``, price). - The price of each flight will be in the range
[1, 10000]. kis in the range of[0, n - 1].- There will not be any duplicated flights or self cycles.
分析
无
代码
1 | class Solution { |
Author: Hatton.Liu
Link: http://hattonl.github.io/2020/03/29/leetcode-787/
License: 知识共享署名-非商业性使用 4.0 国际许可协议