Your question is Graph DFS Problem Solving. 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.
Gro Intelligence represents data lineage as a directed graph. An edge [u, v] means that lineage node u directly depends on node v. A cyclic component indicates mutually dependent calculations that cannot be resolved in a valid dependency order.
Given n nodes labeled 0 through n - 1 and a list of directed edges, return every cyclic strongly connected component. A component is cyclic if it contains at least two nodes, or if it contains one node with a self-loop. Exclude nodes that are not part of a cycle.
Return the components as a list of lists. Sort node IDs within each component in ascending order, and sort the components by their smallest node ID.
Implement find_cyclic_components(n, edges).
n and list edges, where each edge is a two-element list [u, v].def find_cyclic_components(n, edges):