Amazon Interview Question

They asked me to implement an algorithm to detect cycles in a graph and explain my approach step by step.