-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2024-12-04] yerin #365 #368
base: main
Are you sure you want to change the base?
Conversation
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]: | ||
degree = [0] * numCourses | ||
courses = [[] for _ in range(numCourses)] | ||
visited = set() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
방문처리를 위한 set이 없어도 상관없을 것 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
접근 방식이 동일하여 쉽게 이해했습니다. 수고하셨습니다.
now = q.popleft() | ||
if now in visited: | ||
ans = [] | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
바로 return 하면 될 것 같습니다!
PR Summary
<풀이 시간>
20분
<문제 회고>
이전에 알게된 위상정렬을 활용하여 문제를 풀었다. 사이클이 있는지를 확인하는 과정에서 처음에 리스트에 in을 썼더니 시간이 느리게 나와, set을 따로 만들어주었다. 이전에 풀었던 문제와 큰 차이가 있지 않아서 생각보다 금방 문제가 풀렸다.