Parallel Courses (Minimum Semesters)
Medium
Topological Sort & DAG
There are n courses. Each relation 'a b' means course a must be taken before course b. You can take any number of courses per semester as long as their prerequisites were completed in earlier semesters. Print the minimum number of semesters to finish all courses, or -1 if impossible.
Constraints
1 <= n <= 5000 0 <= m <= 5000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.