Your question is Detect Cycles in Resource 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 representing resource allocation dependencies between microservices, determine whether the graph contains a cycle. The input consists of an integer n for the number of nodes labeled 0 to n - 1, and a list of directed edges edges where each edge [u, v] means service u is waiting on service v. Return True if any cycle exists, otherwise return False.
def has_cycle(n, edges):