Problem
Ask
Submissions

Problem: Course Schedule

Medium
30 min
Explore the course scheduling problem where you determine if all courses can be finished given prerequisite constraints. Learn to apply topological sort to assess dependencies and detect if a valid course order exists, helping you approach similar coding interview questions effectively.

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 [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:

  • 11 \leq num_courses 1500\leq 1500
  • 00 \leq prerequisites.length 1000\leq 1000
  • prerequisites[i].length =2= 2
  • 00 \leq a[i], b[i] << num_courses
  • All the pairs prerequisites[i] are unique.
Problem
Ask
Submissions

Problem: Course Schedule

Medium
30 min
Explore the course scheduling problem where you determine if all courses can be finished given prerequisite constraints. Learn to apply topological sort to assess dependencies and detect if a valid course order exists, helping you approach similar coding interview questions effectively.

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 [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:

  • 11 \leq num_courses 1500\leq 1500
  • 00 \leq prerequisites.length 1000\leq 1000
  • prerequisites[i].length =2= 2
  • 00 \leq a[i], b[i] << num_courses
  • All the pairs prerequisites[i] are unique.