Loading repovive.com/problems/classics/18
Given a directed acyclic graph (DAG) with vertices and edges, find a topological ordering of the vertices using DFS-based algorithm.
A topological ordering is a linear ordering of vertices such that for every directed edge , vertex comes before .
Output the topological ordering produced by starting DFS from the highest-numbered unvisited vertex and processing neighbors in reverse order of their vertex numbers. If the graph contains a cycle, output -1.