-
-
Notifications
You must be signed in to change notification settings - Fork 303
[mandel-17] WEEK 01 solutions #2024
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
|
@DaleStudy 리뷰해줘 |
|
좋은 시도와 열정을 보여주셔서 정말 잘하셨어요! 여러 문제를 해결하려고 하는 모습이 인상적입니다. 몇 가지 피드백을 드리자면, 이로써 더 효율적이고 가독성 좋은 코드로 발전하실 수 있을 것 같아요.
def containsDuplicate(self, nums: List[int]) -> bool:
seen = set()
for num in nums:
if num in seen:
return True
seen.add(num)
return False이 방법은 불필요한 반복문과 조건을 제거하여 가독성도 높이고 효율적입니다.
import heapq
from collections import Counter
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
count = Counter(nums)
return [item for item, _ in heapq.nlargest(k, count.items(), key=lambda x: x[1])]이 방식은
def twoSum(self, nums: List[int], target: int) -> List[int]:
hash_map = {}
for i, num in enumerate(nums):
complement = target - num
if complement in hash_map:
return [hash_map[complement], i]
hash_map[num] = i이 방법은 검색과 저장을 한 번씩만 수행하므로 효율적입니다. 전반적으로:
계속해서 도전하는 모습이 멋지고, 발전 가능성도 무궁무진합니다. 화이팅입니다! |
TonyKim9401
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.
1주차 문제 풀이 고생하셨습니다!
온보딩 및 스터디 적응 하시는데 앞으로 조금 더 힘내주시고 앞으로의 15주간 여정 응원합니다.
2주차 문제 풀이도 파이팅입니다!
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!