O45
Course Schedule (Cycle Detection)
Problem Statement & Objective
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. Return True if you can finish all courses.
Function Signature (Python)
course_schedule_cycle_detection(num_courses: int, prerequisites: list[list[int]]) -> boolInput & Output Contract
Output Rule:True veya False.
System Constraints
1 <= ders_sayisi <= 2000
0 <= on_kosullar.length <= 5000
0 <= a, b < ders_sayisi, a != bExample Execution Walkthrough
ders_sayisi = 2, on_kosullar = [[1, 0]] -> önce 0 sonra 1 alınır -> True
ders_sayisi = 2, on_kosullar = [[1, 0], [0, 1]] -> döngü var -> FalseExample Test Scenarios (3)
Example 1: Valid
Input:
[2,[[1,0]]]Expected Output:
trueExample 2: 2'li Döngü
Input:
[2,[[1,0],[0,1]]]Expected Output:
falseExample 3: Doğrusal
Input:
[3,[[0,1],[1,2]]]Expected Output:
true