Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 롤토체스 api dart
- flutter statefulwidget
- dart new
- 롤 api dart
- lol api dart
- PlatformException(sign_in_failed
- dart.dev
- flutter widget
- valorant api dart
- keychain error
- swift 동시성
- flutter android 폴더
- flutter
- 파이썬 부동소수점
- AnimationController
- riot api dart
- flutter ios 폴더
- leetcode dart
- 파이썬
- widget
- generate parentheses dart
- dart
- 발로란트 api dart
- tft api dart
- Architectural overview
- com.google.GIDSignIn
- docker overview
- flutter bloc
- dart new 키워드
- swift concurrency
Archives
- Today
- Total
aspe
LeetCode - 207. Course Schedule (Python) 본문
Python
class Solution:
def canFinish(self, numCourses: int, prerequisites: List[List[int]]) -> bool:
graph = collections.defaultdict(list)
for a, b in prerequisites:
graph[a].append(b)
visited = set()
traced = set()
def dfs(i):
if i in visited:
return True
if i in traced:
return False
traced.add(i)
for y in graph[i]:
if not dfs(y):
return False
traced.remove(i)
visited.add(i)
return True
for x in list(graph):
if not dfs(x):
return False
return True
Comments