Yahoo interview question

topological sorting