Medium Accuracy: 35.66%
Submissions: 100k+ Points: 4
Given an undirected graph with V vertices and E edges, check whether it contains any cycle or not.
Explanation: 1->2->3->4->1 is a cycle.
Input: Output: 0
Explanation: No cycle in the graph.
You don't need to read or print anything. Your task is to complete the function isCycle() which takes V denoting the number of vertices and adjacency list as input parameters and returns a boolean value denoting if the undirected graph contains any cycle or not, return 1 if a cycle is present else return 0.
NOTE: The adjacency list denotes the edges of the graph where edges[i] and edges[i] represent an edge.
Expected Time Complexity: O(V + E) Expected Space Complexity: O(V)