Skip to main content
mediumBlind 75

Course Schedule

Given numCourses and prerequisites array where [a, b] means take b before a Return True if you can finish all courses (no cycle in dependency graph) Example: numCourses = 2, prerequisites = [[1,0]] => True Example: numCourses = 2, prerequisites = [[1,0],[0,1]] => False (cycle)

Prerequisites are edges. I peel off every course with nothing blocking it, and whatever refuses to peel is the cycle.

BFS / DFSGraphsHeap / Priority Queue

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Can Finish All Coursesmedium
2Part 2
3Part 3

Each locked part opens in the editor once the part before it passes.

Based onLeetCode