Loading repovive.com/problems/classics/17
Given a directed acyclic graph (DAG) with vertices and edges, find a topological ordering of the vertices using Kahn's algorithm (BFS-based).
A topological ordering is a linear ordering of vertices such that for every directed edge , vertex comes before .
If multiple valid orderings exist, output the lexicographically smallest one.
If the graph contains a cycle, output -1.