you give integer n indicate n course label 1 n you give 2D integer array relations relationsj prevCoursej nextCoursej denote course prevCoursej complete course nextCoursej prerequisite relationship furthermore give 0indexed integer array time timei denote month take complete i1th courseYou find minimum number month need complete course follow rulesyou start take course time prerequisite metany number course take timereturn minimum number month need complete coursesNote the test case generate possible complete course ie graph direct acyclic graph Example 1input n 3 relation 1323 time 325output 8explanation the figure represent give graph time require complete course we start course 1 course 2 simultaneously month 0course 1 take 3 month course 2 take 2 month complete respectivelythus early time start course 3 month 3 total time require 3 5 8 monthsexample 2input n 5 relation 1525353445 time 12345output 12explanation the figure represent give graph time require complete courseyou start course 1 2 3 month 0you complete 1 2 3 month respectivelycourse 4 take course 3 complete ie 3 month it complete 3 4 7 monthscourse 5 take course 1 2 3 4 complete ie max1237 7 monthsThus minimum time need complete course 7 5 12 month Constraints1 n 5 1040 relationslength minn n 1 2 5 104relationsjlength 21 prevCoursej nextCoursej nprevCoursej nextcoursejall pair prevCoursej nextCoursej uniquetimelength n1 timei 104the give graph direct acyclic graph