Your question is Cycle Detection in Directed Graphs. 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.
Juspay Hyper can model payment-processing steps as directed dependencies, where an edge from step A to step B means A must complete before B starts. Given this dependency graph, determine whether it contains a directed cycle.
Implement has_cycle(graph). Return True if any directed cycle exists, otherwise return False.
graph, a dictionary mapping each node name, represented by a string, to a list of neighboring node names.True when the graph contains at least one directed cycle; otherwise return False.def has_cycle(graph):