Skip to main content
Course Schedule II | AlgoCracked
AlgoCracked
ProblemsCourse Schedule II
Medium49.0% acceptance
Blind75DfsBfsGraphTopological Sort

Course Schedule II

There are numCourses courses labelled 0…numCourses-1 . prerequisites[i] = [a, b] means course b must be taken before course a . Return an order in which all courses can be finished, or an empty array if it is impossible. To make the answer unique: whenever several courses are available (all prerequisites met), take the one with the smallest number first. Input format Input is [numCourses, prerequisites] , e.g. [2,[[1,0]]] .

Loading workspace…