ByteDance interview question

Graph problem, likely to be topological sort