X Interview Question

Topological sorting.