题目:原题链接(中等)
标签:图、有向图
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
Ans 1 (Python) | O ( E ) | O ( N ) | 192ms (33%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
point = set([i for i in range(n)])
for edge in edges:
if edge[1] in point:
point.remove(edge[1])
return list(point)