Intuit Interview Question

A coding problem using topological sorts