Atlassian Interview Question

graph based question, to be solved using dfs