Detect whether there is a cycle in an undirected graph. (Introductory concept)
{
"V": 4,
"adj": [
[
1
],
[
0,
2,
3
],
[
1,
3
],
[
1,
2
]
]
}true{
"V": 3,
"adj": [
[
1
],
[
0,
2
],
[
1
]
]
}false{
"V": 5,
"adj": [
[
1
],
[
0,
2
],
[
1,
3
],
[
2,
4
],
[
3
]
]
}falseSign in to Run Code and Submit