(crs)
| 10 | visiting = set() |
| 11 | |
| 12 | def dfs(crs): |
| 13 | if crs in visiting: |
| 14 | return False |
| 15 | if preMap[crs] == []: |
| 16 | return True |
| 17 | |
| 18 | visiting.add(crs) |
| 19 | for pre in preMap[crs]: |
| 20 | if not dfs(pre): |
| 21 | return False |
| 22 | visiting.remove(crs) |
| 23 | preMap[crs] = [] |
| 24 | return True |
| 25 | |
| 26 | for c in range(numCourses): |
| 27 | if not dfs(c): |