1557. Minimum Number of Vertices to Reach All Nodes

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1557

class Solution:
    def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
        cnt = Counter(t for _, t in edges)
        return [i for i in range(n) if cnt[i] == 0]