Leetcode 1661 Solution

This article provides solution to leetcode question 1661 (minimum-number-of-vertices-to-reach-all-nodes)

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]