Yahoo Interview Question

Topological sorting