Whats wrong with my code? Can you fix it?
Your mistake
- at line no 39
for (auto p : visited)
{
visited[p.first] = false;
stack[p.first] = false;
}
you have to traverse in adjlist l not in visited map
- at line no 18
if (stack[node] == true)
this will be always true
instead you have to check
if(stack[nbr]==true)
Modified code