Back to problems

Find Course Order

Algorithm · Google · Medium

You need to finish numCourses courses, labeled from 0 up to numCourses - 1. The list prerequisites contains dependency pairs in which each entry prerequisites[i] = [a, b] states that course b has to be completed before course a can be started. Produce one ordering of all the courses that respects every dependency. If the dependencies make it impossible to complete every course, return an empty array. Constraints 1 <= numCourses <= 2000 0 <= prerequisites.length <= 5000…

Loading the rest of the question…