Detecting Cycles In Course Prerequisites Using DFS
Cannot complete courses due to loop in prerequisites. Use DFS to detect loops and return false. Example: [[1,0],[0,1]] has a loop, cannot complete 2 courses.
U can read the question properly and give a try once before coming to the solution Incase you have tried and need help you can continue through the solution 🤗 Taking the *Example - 1 * Input: numCourses = 2, prerequisites = [[1,0]] so this tells us that we need to be completing 2 courses and in order to complete course 1 we need to complete course 0 so this is possible as u can first complete course0 and then course 1 Taking the Example - 2 Input: numCourses = 2, prerequisites = [[1,0],[0,1]] so here we want to complete the 2 courses course 1 and course 0 , and the prerequisites tell us that...