You are given courses labeled from to . You are also given an array relations where relations[j] = [prevCourse_j, nextCourse_j] means course must be completed before course . Each course takes time[i] months to complete.
You can start multiple courses at the same time as long as their prerequisites are met. Find the minimum number of months needed to complete all courses.
Example: , , . Courses and start in parallel. Course starts after both finish (month ). Total: months.