NeetCode #609LC-1136MediumGraphsNC Algo100
← Back to All Problems

#609 · #1136 · Parallel Courses(并行课程)

📌 Problem Statement & Constraints

You are given n courses and relations where relations[i] = [a, b] means course a must be taken before b. In one semester you may take any number of courses whose prerequisites are all satisfied. Return the minimum number of semesters, or -1 if impossible. Constraints: 1 <= n <= 5000, 1 <= relations.length <= 5000.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!