Back to problems

Course Schedule and Topological Sort on a Directed Graph

Algorithm · ByteDance · Medium

Requirements This problem has two standard forms: Feasibility: Given numCourses and prerequisite pairs [a, b], where each pair represents the directed prerequisite relation $$b \to a$$, determine whether all courses can be completed in some valid order. Order: Using the same inputs, return any valid sequence containing the courses, or return an empty list when no such sequence exists. Reported variants include: SRE coding round: Treat the prerequisite relationships as…

Checking your access…