13. Cycle Detection Introduction
Easy

Problem Statement

Detect whether there is a cycle in an undirected graph. (Introductory concept)

Examples

1Example 1
Input:
{ "V": 4, "adj": [ [ 1 ], [ 0, 2, 3 ], [ 1, 3 ], [ 1, 2 ] ] }
Output:
true
2Example 2
Input:
{ "V": 3, "adj": [ [ 1 ], [ 0, 2 ], [ 1 ] ] }
Output:
false
3Example 3
Input:
{ "V": 5, "adj": [ [ 1 ], [ 0, 2 ], [ 1, 3 ], [ 2, 4 ], [ 3 ] ] }
Output:
false
Loading...

Sign in to Run Code and Submit