-
-
Notifications
You must be signed in to change notification settings - Fork 195
[i-mprovising] Week 01 solutions #1167
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
nums_set = set(nums) | ||
if len(nums) == len(nums_set): | ||
return False | ||
return True |
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을 이용해서 중복을 없앤뒤 기존 배열과 비교해서 처리한 부분이 저랑 비슷한 풀이같네요👍
@i-mprovising |
넵 확인 감사합니다! |
for i, x in enumerate(nums): | ||
y = target - x | ||
if (y in table) and table[y] != i: | ||
return [i, table[y]] |
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.
첫 번째 루프에서 table을 미리 만드는 것보다는, enumerate로 순회하면서 동시에 dict에 저장해서
개선해 볼 수 있을거같아
의견 남깁니다.
ex)
table = {}
for i, num in enumerate(nums):
complement = target - num
if complement in table:
return [table[complement], i]
table[num] = i
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.
상세한 리뷰 감사합니다!
굳이 루프를 더 쓸 필요가 없네요.
@i-mprovising 확인 완료하였습니다. |
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!