Pergunta de entrevista da empresa NVIDIA

Find a cycle in a graph with nodes connected by uni-directional links.

Resposta da entrevista

Sigiloso

14 de jan. de 2013

Traverse the graph with DFS, and mark each node you traverse. Unmark each node when all of its sons has been visited. If you arrive on a node which is already marked, then you have found a cycle.