Google Interview Question

Related to toposort in graphs.