You are given an integer n, indicating that there are n courses labeled from n. You are also given an array relations where relations[i] = [prevCourse_i, nextCourse_i], representing that course prevCourse_i must be completed before course nextCourse_i can be taken, and an integer k.
In one semester, you can complete at most k courses as long as all prerequisite courses for them have been completed in previous semesters.
Return the minimum number of semesters required to take all n courses.
Constraints:
n
k n
relations.length n $ imes ($n
relations[i].length
prevCourse_i, nextCourse_i n
prevCourse_i nextCourse_i
All the pairs [prevCourse_i, nextCourse_i] are unique.
The given graph is a directed acyclic graph.
You are given an integer n, indicating that there are n courses labeled from n. You are also given an array relations where relations[i] = [prevCourse_i, nextCourse_i], representing that course prevCourse_i must be completed before course nextCourse_i can be taken, and an integer k.
In one semester, you can complete at most k courses as long as all prerequisite courses for them have been completed in previous semesters.
Return the minimum number of semesters required to take all n courses.
Constraints:
n
k n
relations.length n $ imes ($n
relations[i].length
prevCourse_i, nextCourse_i n
prevCourse_i nextCourse_i
All the pairs [prevCourse_i, nextCourse_i] are unique.
The given graph is a directed acyclic graph.