Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[2024-12-04] yerin #365 #368

wants to merge 1 commit into from

Conversation

blaire-pi
Copy link
Collaborator

PR Summary

<풀이 시간>
20분

<문제 회고>
이전에 알게된 위상정렬을 활용하여 문제를 풀었다. 사이클이 있는지를 확인하는 과정에서 처음에 리스트에 in을 썼더니 시간이 느리게 나와, set을 따로 만들어주었다. 이전에 풀었던 문제와 큰 차이가 있지 않아서 생각보다 금방 문제가 풀렸다.

image

@blaire-pi blaire-pi self-assigned this Dec 4, 2024
@blaire-pi blaire-pi linked an issue Dec 4, 2024 that may be closed by this pull request
def findOrder(self, numCourses: int, prerequisites: List[List[int]]) -> List[int]:
degree = [0] * numCourses
courses = [[] for _ in range(numCourses)]
visited = set()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

방문처리를 위한 set이 없어도 상관없을 것 같아요!

Copy link
Collaborator

@HeewonKwak HeewonKwak left a 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

바로 return 하면 될 것 같습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[2024-12-04]: 210. Course Schedule II
4 participants