Course Schedule

Try to solve the Course Schedule problem.

Statement

There are a total of numCourses courses you have to take. The courses are labeled from 0 to numCourses - 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 [1,0][1, 0] indicates that to take course 11, you have to first take course 00.

Return TRUE if all of the courses can be finished. Otherwise, return FALSE.

Constraints:

  • 1≤1 \leq numCourses ≤1500\leq 1500
  • 0≤0 \leq prerequisites.length ≤1000\leq 1000
  • prerequisites[i].length =2= 2
  • 0≤0 \leq a[i], b[i] << numCourses
  • 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