Walmart Interview Question

Question on topological sorting.