You'll move away from grids and look at logical graphs. Imagine you are choosing university courses. To take Course A, you must finish Course B. To take Course B, you must finish Course A. Can you graduate?
No. You are stuck in a cycle. Detecting these cycles is a classic graph application. You will model dependencies as directed edges. If the graph has a cycle, the tasks are impossible to complete. DFS helps you find cycles by tracking which nodes are in the current recursion path.