DoorDash interview question

Some variations Of DFS algorithm