Your question is Detect Cycles in Directed Graph. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a directed graph with n nodes labeled from 0 to n - 1 and a list of directed edges edges, determine whether the graph contains a cycle. Return True if any cycle exists and False otherwise. The graph may be disconnected.
def has_cycle(n, edges):