Pregunta de entrevista de Google

Graph problem. Involving to do a topological sort.