Pergunta de entrevista da empresa Google

Graph problem. Involving to do a topological sort.