Atlassian interview question

graph based question, to be solved using dfs