-
-
Notifications
You must be signed in to change notification settings - Fork 248
[jiunshinn] WEEK01 solutions #1692
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
# 시간 복잡도 : o(n) | ||
# 공간 복잡도 o(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.
시간 복잡도에는 :
를 쓰시고, 공간 복잡도에는 쓰시지 않는 이유가 궁금하네요?
|
||
class Solution: | ||
def containsDuplicate(self, nums: List[int]) -> bool: | ||
seen = 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.
집합을 사용하는 이 풀이가 위에 사전을 쓰는 풀이보다 더 깔끔한 것 같습니다!
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.
첫 주 수고하셨습니다. 2주차도 화이팅입니다 :)
for i, n in enumerate(nums): | ||
diff = target - n | ||
if diff in hashmap: | ||
return [i, hashmap[diff]] |
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 [i, hashmap[diff]] 대신 return [hashmap[diff], i]로 수정하는 것이 안전합니다.
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!