Walmart interview question

Question on topological sorting.