Leetcode 1661 Solution
This article provides solution to leetcode question 1661 (minimum-number-of-vertices-to-reach-all-nodes)
Access this page by simply typing in "lcs 1661" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes
Solution
class Solution:
def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
m = {dst for _, dst in edges}
return [i for i in range(n) if i not in m]