Back to problems

Topological Sort / Course Schedule for Ads

Algorithm · Netflix · Medium

You are a student planning your academic journey. There are numCourses courses you must complete, labeled from 0 to numCourses - 1. Some courses have prerequisites: for example, to take course a you must first complete course b. These dependencies are given as a list of pairs [a, b], meaning b is a prerequisite of a (you must finish b before starting a). Your task is to determine whether it is possible to finish all courses. If the dependency graph contains a cycle, it is…

Checking your access…