Problem title
Difficulty
Avg time to solve

Shortest substring with all characters
Moderate
18 mins
Minimum Time in Wormhole Network
Hard
44 mins
Is It A Tree?
Moderate
20 mins
Delete Leaf Nodes With Value X
Moderate
27 mins
Detect Cycle in a Undirected Graph
Hard
50 mins
Minimize The Difference
Easy
20 mins
Loudspeakers
Moderate
20 mins
Maximum Time
Easy
15 mins
Check Permutation
Easy
--
Occurs Once
Easy
10 mins
11

Detect Cycle in a Undirected Graph

Difficulty: HARD
Avg. time to solve
50 min
Success Rate
50%

Problem Statement

Given an undirected graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least one cycle, else return false.

Input format :
Line 1 : Graph of type graph class
Output Format :
return true or false
Sample Input 1:
for graph with edges
(0,1);(1,2);(0,3);(3,4);(0,2)
Sample Output 1:
True 
Reset Code
Full screen
copy-code
Console