Yahoo interview question

Topological sorting