Skip to content

Conversation

@mandel-17
Copy link
Contributor

@mandel-17 mandel-17 commented Nov 15, 2025

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@mandel-17
Copy link
Contributor Author

@DaleStudy 리뷰해줘

@dalestudy
Copy link
Contributor

dalestudy bot commented Nov 15, 2025

좋은 시도와 열정을 보여주셔서 정말 잘하셨어요! 여러 문제를 해결하려고 하는 모습이 인상적입니다. 몇 가지 피드백을 드리자면, 이로써 더 효율적이고 가독성 좋은 코드로 발전하실 수 있을 것 같아요.

  1. 시간/공간 복잡도 분석 요청:
    각 솔루션에 대한 시간과 공간 복잡도를 명시하는 것을 권장합니다. 예를 들어, containsDuplicate은 현재 O(n^2) (내부 in 연산이 리스트 전체 검색으로 O(n)) 시간복잡도를 갖고 있는데, 더 효율적 방법이 존재합니다. 이를 O(n)으로 개선 가능하며, 이점을 명시하면 가독성과 이해가 더 좋아집니다.

  2. containsDuplicate 개선 제안:
    현재 방법은 리스트에서 중복을 찾기 위해 리스트를 계속 확장하며 검색하는 구조로, 시간 복잡도가 높습니다. 대신 set을 활용하면 O(n)의 시간복잡도를 달성할 수 있습니다:

def containsDuplicate(self, nums: List[int]) -> bool:
    seen = set()
    for num in nums:
        if num in seen:
            return True
        seen.add(num)
    return False

이 방법은 불필요한 반복문과 조건을 제거하여 가독성도 높이고 효율적입니다.

  1. topKFrequent 개선 제안:
    현재는 딕셔너리로 빈도수를 세고 정렬하여 해결하는 방식입니다. 이는 O(n log n) 시간복잡도를 갖지만, 힙 자료구조를 이용하면 더욱 효율적입니다:
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])]

이 방식은 O(n log k)로 더 빠를 수 있습니다.

  1. twoSum 개선 제안:
    현재는 in 연산으로 O(n) 검색이 반복되어 전체 시간복잡도가 O(n^2)가 됩니다. 더 좋은 방법은 딕셔너리로 한 번만 순회하며 O(n)에 해결하는 것:
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

이 방법은 검색과 저장을 한 번씩만 수행하므로 효율적입니다.

전반적으로:

  • 가독성을 위해 변수명과 구조를 좀 더 명확히 다듬으면 좋겠어요.
  • 각 문제에 시간/공간 복잡도 분석을 포함시키면 학습에 큰 도움이 됩니다.
  • 이미 좋은 시도를 보여주셨기 때문에, 제안드린 방식들로 개선한다면 더욱 뛰어난 해결책이 될 겁니다!

계속해서 도전하는 모습이 멋지고, 발전 가능성도 무궁무진합니다. 화이팅입니다!

Copy link
Contributor

@TonyKim9401 TonyKim9401 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1주차 문제 풀이 고생하셨습니다!
온보딩 및 스터디 적응 하시는데 앞으로 조금 더 힘내주시고 앞으로의 15주간 여정 응원합니다.
2주차 문제 풀이도 파이팅입니다!

@dalestudy dalestudy bot added this pull request to the merge queue Nov 16, 2025
@DaleSeo DaleSeo removed this pull request from the merge queue due to the queue being cleared Nov 16, 2025
@dalestudy dalestudy bot added this pull request to the merge queue Nov 16, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 16, 2025
@dalestudy dalestudy bot added this pull request to the merge queue Nov 17, 2025
Merged via the queue into DaleStudy:main with commit 10e5a5b Nov 17, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 6기 Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

2 participants