Pergunta de entrevista da empresa ByteDance

Graph problem, likely to be topological sort