|
1 | 1 | # https://leetcode.com/problems/course-schedule-ii/
|
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, return the |
7 |
| -# ordering of courses you should take 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, return the ordering of |
| 7 | +# courses you should take to finish all courses. |
8 | 8 | #
|
9 | 9 | # There may be multiple correct orders, you just need to return one of them.
|
10 | 10 | # If it is impossible to finish all courses, return an empty array.
|
11 | 11 | #
|
12 | 12 | # For example:
|
13 | 13 | #
|
14 |
| -# 2, [[1,0]] |
| 14 | +# 2, [[1, 0]] |
15 | 15 | #
|
16 | 16 | # There are a total of 2 courses to take. To take course 1 you should have
|
17 |
| -# finished course 0. So the correct course order is [0,1] |
| 17 | +# finished course 0. So the correct course order is [0, 1] |
18 | 18 | #
|
19 |
| -# 4, [[1,0],[2,0],[3,1],[3,2]] |
| 19 | +# 4, [[1, 0], [2, 0], [3, 1], [3, 2]] |
20 | 20 | #
|
21 | 21 | # There are a total of 4 courses to take. To take course 3 you should have
|
22 | 22 | # finished both courses 1 and 2. Both courses 1 and 2 should be taken after
|
23 |
| -# you finished course 0. So one correct course order is [0,1,2,3]. Another |
24 |
| -# correct ordering is [0,2,1,3]. |
| 23 | +# you finished course 0. So one correct course order is [0, 1, 2, 3]. Another |
| 24 | +# correct ordering is [0, 2, 1, 3]. |
| 25 | +# |
| 26 | +# Note: The input prerequisites is a graph represented by a list of edges, not |
| 27 | +# adjacency matrices. |
25 | 28 |
|
26 | 29 |
|
27 | 30 | # @param {Integer} num_courses
|
|
0 commit comments