DIY: Course Schedule

Solve the interview question "Course Schedule" in this lesson.

Problem statement

You will be given an integer num_courses representing the number of courses. The courses are labeled from 0 to num_courses - 1. You will also be given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take the course ai. For example, the pair [1, 0], indicates that to take course 1 you have to first take course 0.

You will have to return true if all of the courses can be finished, otherwise false.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.