Houzz Interview Question

how would you detect a cycle in a DAG.

Interview Answers

Anonymous

Oct 24, 2015

If you ever come back to the same node twice, then there is a cycle.

Anonymous

Oct 22, 2016

perhaps...close your eyes and pray for a miracle.

1

Anonymous

Sep 25, 2019

you just have to know if there is a backward edge using DFS