-
-
Notifications
You must be signed in to change notification settings - Fork 304
[doh6077] WEEK 02 solutions #2048
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
Conversation
|
안녕하세요! 풀이 고생하셨습니다~ |
| class Solution: | ||
| def isValidBST(self, root: Optional[TreeNode]) -> bool: | ||
| def validate(node: Optional[TreeNode], low: float, high: float) -> bool: | ||
| if not node: | ||
| return True | ||
| if not (low < node.val < high): | ||
| return False | ||
| return (validate(node.left, low, node.val) and | ||
| validate(node.right, node.val, high)) | ||
| return validate(root, float('-inf'), float('inf')) |
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.
재귀적으로 잘 푸신 것 같습니다!
|
|
||
| for i in range(n - 2): | ||
| # i 중복 스킵 | ||
| if i > 0 and nums[i] == nums[i - 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.
이 조건문이 없으면 제출 테스트케이스 끝자락에서 오류가 발생하더라구요..
[0, 0, 0, 0 ...] 이런 상황에서 유용하게 쓰일 것 같습니다👍
| class Solution: | ||
| # dictionary use | ||
| def topKFrequent(self, nums: List[int], k: int) -> List[int]: | ||
| result = {} # key: 원소, value: 등장 횟수 |
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.
해시 테이블을 활용해서 횟수 계산 로직이 명확하고 가독성이 좋아 이해하기 쉬운 코드였습니다👍
yuhyeon99
left a comment
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.
이번 주도 고생하셨습니다~
climbing stars 문제가 생각보다 어려워서 나중에 푸려고 제외시켜놓고 누락시켜버렸네요 ㅠ 다음에 다시 확인하도록 하겠습니다 :) 좋은 리뷰 주셔서 감사합니다! 다음 한주도 파이팅입니다! |
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!