일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 |
Tags
- 컴퓨터의 구조
- 30. Substring with Concatenation of All Words
- t1
- data science
- Python
- LeetCode
- shiba
- DWG
- 운영체제
- kaggle
- iterator
- Python Code
- Generator
- 시바견
- 315. Count of Smaller Numbers After Self
- concurrency
- 프로그래머스
- attribute
- Protocol
- Python Implementation
- Convert Sorted List to Binary Search Tree
- Regular Expression
- 파이썬
- 715. Range Module
- Class
- Substring with Concatenation of All Words
- 43. Multiply Strings
- 109. Convert Sorted List to Binary Search Tree
- 밴픽
- Decorator
Archives
- Today
- Total
목록cheapest flights within k stops (1)
Scribbling
LeetCode: 787. Cheapest Flights Within K Stops
src로부터 특정 dst까지의 최단 거리를 묻는 문제로, 다익스트라 알고리즘을 먼저 떠올릴 수 있다. 기본적인 형태의 다익스트라 알고리즘은, priority queue에 "최단 거리가 갱신되는 경우"를 추가한다. 하지만 이 문제는 "이동 횟수 제한"이 있으므로, 이를 수정해야한다. 즉, priority queue에 "최단 거리가 갱신되는 경우"를 추가하는 것이 아니라, "추가적으로 이동 가능한 경우"를 모두 추가할 필요가 있다. 이를 코드로 구현하면 아래와 같다. import heapq class Solution: def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, k: int) -> int: INF = int..
Computer Science/Coding Test
2021. 8. 12. 13:26