Skip to content
C

Detect Cycle in Undirected Graph

Mediumjavapythonccppjavascript

Given an undirected graph, determine whether it contains at least one cycle.

Input Format

The first line contains two integers V and E. Each of the next E lines contains an undirected edge u v.

Output Format

Print 1 if the graph contains a cycle, otherwise print 0.

Input (stdin)

Output

Run your code to see output here...