Mid-levelMid (3–6 yrs)CodingPythonAmazonGoogleTikTok
Course Schedule (Detect Cycle)
There are numCourses labeled 0..n-1 and prerequisites [a,b] meaning b before a. Return true if you can finish all courses (i.e., the graph is a DAG).
Answers use simple, clear English.
Time: O(V+E)Space: O(V+E)
Confidence
#topo-sort#graph