Given a list of courses with dependencies, where courses can be completed in batches. Calculate the minimum time to complete all courses. Each course has a specific time requirement, and you must wait for an entire batch to complete before starting the next batch.
Rules:
Courses in the same batch (same topological level) can be taken in parallel
Must wait for the entire batch to finish before starting the next
Batch completion time = max time among all courses in that batch
Constraints:
0 ≤ numCourses ≤ 2000
0 ≤ prerequisites.length ≤ 5000
Each course time ≥ 1
Must detect cycles (if cycle exists, return -1)
Follow-ups:
Each course takes unit time (1), return total number of levels
Given time array where time[i] is duration for course i, return total time with batch completion
What if a course can start as soon as ALL its dependencies finish (not batch-based)? Use Dijkstra-like approach.