Can you please tell how to approach in case there are more than 1 components in the adjacency list
Cycle detection using DFS
hello @G_rahil
use an array to keep track of visited node.
first initialise this array with false.
then start iterating from 1 to n.
if vis[i]==false
call ur cycle detection function and pass this array along with it .
this will handle evrry case