NVIDIA interview question

Topologically sort a DAG and detect cycles