Phase 1: Try to schedule courses — discover the impossibility
Five Courses. Simple Prerequisites.
— Confession:I once spent twenty minutes manually trying to find a valid schedule for a set of courses before I realized the problem was asking whether one EXISTS — not asking me to FIND it. The courses had a circular dependency, and no amount of rearranging would fix it. The algorithm's job is to detect the impossibility, not to solve through it.
Course 0 requires Course 1 and Course 2. Course 1 requires Course 3. Course 2 requires both Course 3 and Course 4. These are directed prerequisites — an arrow from A to B means “A before B.” Tap courses in a valid order: you can only take a course after all its prerequisites.
Five courses, directed prerequisites
Tap the courses you could take on day one.
Read the arrows. An arrow into a course is something it needs first. Tap every course you could take on day one, then lock it in.