Snap Interview Question

topological sort