Pergunta de entrevista da empresa Atlassian

graph based question, to be solved using dfs