Course Schedule
Try to solve the Course Schedule problem.
We'll cover the following
Statement
You are given an integer, num_courses
, representing the total number of courses you need to complete, labeled from 0
to num_courses - 1
.
You are also given a prerequisites
array, where prerequisites[i] = [a[i], b[i]]
indicates that you must take course b[i]
first if you want to take the course a[i]
. For example, the pair indicates that to take course , you have to first take course .
Return TRUE if all of the courses can be finished. Otherwise, return FALSE.
Constraints:
-
num_courses
-
prerequisites.length
prerequisites[i].length
-
a[i]
,b[i]
num_courses
- All the pairs
prerequisites[i]
are unique.
Examples
Create a free account to view this lesson.
Continue your learning journey with a 14-day free trial.
By signing up, you agree to Educative's Terms of Service and Privacy Policy