Skip to content
C

Detect Cycle in Directed Graph

Mediumjavapythonccppjavascript

Given a directed graph, determine whether it contains a directed cycle.

Input Format

The first line contains two integers V and E. Each of the next E lines contains a directed edge u v (from u to v).

Output Format

Print 1 if a directed cycle exists, otherwise print 0.

Input (stdin)

Output

Run your code to see output here...