We’re preparing your current view and syncing the latest data.
Given a directed acyclic graph, find the minimum number of vertices such that all nodes in the graph are reachable from at least one of these vertices. The graph is given as a list of edges, where each edge represents a directed connection from one vertex to another.
An integer n representing the number of vertices in the graph, and a list of edges where each edge is represented as a pair [from, to].
Return a list of vertices that form the minimum set of vertices from which all nodes in the graph are reachable. The order of vertices in the output does not matter.
1 <= n <= 10^5 0 <= edges.length <= 10^5 edges[i].length == 2 0 <= fromi, toi < n All the pairs [fromi, toi] are unique.