NeetCode #594LC-1557MediumGraphs
← Back to All Problems#594 · #1557 · Minimum Number of Vertices to Reach All Nodes(可以到达所有点的最少点数目)
📌 Problem Statement & Constraints
Given a DAG with
n vertices and edges, return the smallest set of vertices from which all other vertices are reachable. Constraints: 2 <= n <= 10^5, 1 <= edges.length <= min(10^5, n * (n - 1) / 2), all edges are distinct.🔒
Sign In to Unlock Full Solutions for All 973 Problems
Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!