일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- realclass
- 뭐든
- 운동
- 만화도
- 영어공부
- 프로젝트
- Writing
- leetcode
- 미드시청
- 잡생각
- 사이드
- 30분
- 개발자
- 쓰릴오브파이트
- 10분
- 괜찮음
- 화상영어
- Daily Challenge
- 리얼 클래스
- 월간
- 3줄정리
- 매일
- Problem Solving
- 링피트
- 영어원서읽기
- English
- FIT XR
- 파비최
- 스탭퍼
- 읽기
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.05.18 Today's Challenge 본문
https://leetcode.com/problems/minimum-number-of-vertices-to-reach-all-nodes/
Minimum Number of Vertices to Reach All Nodes - LeetCode
Can you solve this real interview question? Minimum Number of Vertices to Reach All Nodes - Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from
leetcode.com
class Solution:
def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
a = set(range(n))
d = set(d for _, d in edges)
s = a - d
return list(s)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.05.20 Today's Challenge (0) | 2023.05.20 |
---|---|
2023.05.19 Today's Challenge (0) | 2023.05.19 |
2023.05.17 Today's Challenge (0) | 2023.05.17 |
2023.05.16 Today's Challenge (0) | 2023.05.16 |
2023.05.15 Today's Challenge (1) | 2023.05.15 |
Comments