|
1 | 1 | # https://leetcode.com/problems/course-schedule/ |
2 | 2 | # |
3 | 3 | # There are a total of n courses you have to take, labeled from 0 to n - 1. |
4 | | -# Some courses may have prerequisites, for example to take course 0 you |
5 | | -# have to first take course 1, which is expressed as a pair: [0,1]. Given |
6 | | -# the total number of courses and a list of prerequisite pairs, is it |
7 | | -# possible for you to finish all courses? |
| 4 | +# Some courses may have prerequisites, for example to take course 0 you have |
| 5 | +# to first take course 1, which is expressed as a pair: [0,1]. Given the total |
| 6 | +# number of courses and a list of prerequisite pairs, is it possible for you |
| 7 | +# to finish all courses? |
8 | 8 | # |
9 | 9 | # For example: |
10 | 10 | # |
11 | | -# 2, [[1,0]] |
| 11 | +# 2, [[1, 0]] |
12 | 12 | # |
13 | | -# There are a total of 2 courses to take. To take course 1 you should |
14 | | -# have finished course 0. So it is possible. |
| 13 | +# There are a total of 2 courses to take. To take course 1 you should have |
| 14 | +# finished course 0. So it is possible. |
15 | 15 | # |
16 | | -# 2, [[1,0],[0,1]] |
| 16 | +# 2, [[1, 0], [0, 1]] |
17 | 17 | # |
18 | | -# There are a total of 2 courses to take. To take course 1 you should |
19 | | -# have finished course 0, and to take course 0 you should also have |
20 | | -# finished course 1. So it is impossible. |
| 18 | +# There are a total of 2 courses to take. To take course 1 you should have |
| 19 | +# finished course 0, and to take course 0 you should also have finished course |
| 20 | +# 1. So it is impossible. |
| 21 | +# |
| 22 | +# Note: The input prerequisites is a graph represented by a list of edges, not |
| 23 | +# adjacency matrices. |
21 | 24 |
|
22 | 25 |
|
23 | 26 | # @param {Integer} num_courses |
|
0 commit comments