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 |
Tags
- widget
- 롤 api dart
- leetcode dart
- 롤토체스 api dart
- riot api dart
- flutter android 폴더
- swift concurrency
- keychain error
- dart new
- flutter bloc
- 파이썬 부동소수점
- tft api dart
- flutter
- 파이썬
- lol api dart
- flutter widget
- generate parentheses dart
- flutter ios 폴더
- AnimationController
- valorant api dart
- com.google.GIDSignIn
- dart.dev
- docker overview
- swift 동시성
- PlatformException(sign_in_failed
- Architectural overview
- flutter statefulwidget
- 발로란트 api dart
- dart
- dart new 키워드
Archives
- Today
- Total
Coaspe
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