Google interview question

Leetcode type question- Graph DFS.