-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Chaedie] Week 11 #1032
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
[Chaedie] Week 11 #1032
Conversation
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.
@Chaedie 님, 11주차도 고생하셨습니다.
코드가 참 예쁘네요 ㅋㅋ 이런게 파이써닉 한거구나 싶습니다!
|
||
class Solution: | ||
def validTree(self, n: int, edges: List[List[int]]) -> bool: | ||
if not n: |
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.
이 문제에는 트리의 성질을 이용한 조기종료 조건이 하나 더 숨어있어요.
시간이 괜찮으시다면 한번 찾아보시는것도 좋을 것 같습니다!
그리고 이 문제만 복잡도 분석이 빠져있는데, 혹시 빠뜨리신걸까 해서 말씀드려요!
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.
감사합니다.. ! 다른 분들 코드 참고를 많이 해서 예뻐진것 같습니다.. 😀
if len(edges) != n - 1: return False
간선의 갯수 < 노드 갯수 - 1
일 경우 연결되지 않은 그래프간선의 갯수 > 노드 갯수 - 1
일 경우 순환이 있는 그래프
라는 조기 종료 조건이 있네요..! 감사합니다.
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.
고생하셨습니다! 확실히 파이썬이 다른 언어들에 비해 알고리즘 문제 풀 때 간결하게 완성하기 좋네요. 다음주도 화이팅입니다! 👍
# Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.