[그래프] K 경유지 내 가장 저렴한 항공권
787 | Cheapest Flights Within K Stops https://leetcode.com/problems/cheapest-flights-within-k-stops/ 작성 코드 (30분 제한) class Solution: def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int: graph = collections.defaultdict(list) for f, t, p in flights: graph[f].append((t, p)) Q = [(0, src, k)] dist = collections.defaultdict(int) answers = [] while Q: price,..
2022. 3. 8.