Detect cycle in directed graph

Java Hard 6 views
Back to Questions

Problem Description

Task: given n and edges, detect if there is a cycle (directed). Use DFS + recursion stack.

Input Format

Java method

Output Format

Return value

Constraints

n can be up to 1e5; avoid heavy recursion if needed.

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next