problem in detecting cycles in directed graph

I have recently coded to detect cycles in directed graph [this][1] is link to my solution. My solution is working fine but I am getting TLE in one test case. Can any one please figure out what is bug in my code.
[1]: import java.io.BufferedReader;import java.io.IOException;import java.io.Inpu - Pastebin.com

Can you share the problem link?

The problem is:
return 0 if directed graph has a cycle and 1 otherwise.

What are the constraints? Also, as @arpit728 pointed out, it’s hard to help you without the problem. We can’t tell if something you do in the code can be removed to decrease the runtime or if it’s essential to solving the problem.

1 Like