MongoDB interview question

Build order topological sort dfs question