Algorithm · Snowflake · Hard
Implement solution(N, edges) for a directed graph whose vertices are numbered 1 through N. Each pair (u, v) in edges represents a directed edge from u to v. Build the adjacency list internally. Your submission must include both a recursive DFS implementation and an iterative DFS implementation using an explicit stack. The solution(N, edges) entry point must use the explicit-stack version so that it works for large inputs without increasing Python's recursion limit. Return a…
Checking your access…