Skip to content

[njngwn] WEEK 01 solutions#2649

Merged
njngwn merged 4 commits into
DaleStudy:mainfrom
njngwn:main
Jun 27, 2026
Merged

[njngwn] WEEK 01 solutions#2649
njngwn merged 4 commits into
DaleStudy:mainfrom
njngwn:main

Conversation

@njngwn

@njngwn njngwn commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

📊 njngwn 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
contains-duplicate Easy ⚠️ 유형 불일치
house-robber Medium ✅ 의도한 유형
longest-consecutive-sequence Medium ⚠️ 유형 불일치
top-k-frequent-elements Medium ✅ 의도한 유형
two-sum Easy ⚠️ 유형 불일치

누적 학습 요약

  • 풀이한 문제: 0 / 75개
  • 이번 주 유형 일치율: 40% (5문제 중 2문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Array □□□□□□□ 0 / 10 ← 아직 시작 안 함
Binary □□□□□□□ 0 / 5 ← 아직 시작 안 함
Dynamic Programming □□□□□□□ 0 / 11 ← 아직 시작 안 함
Graph □□□□□□□ 0 / 8 ← 아직 시작 안 함
Interval □□□□□□□ 0 / 5 ← 아직 시작 안 함
Linked List □□□□□□□ 0 / 6 ← 아직 시작 안 함
Matrix □□□□□□□ 0 / 4 ← 아직 시작 안 함
String □□□□□□□ 0 / 10 ← 아직 시작 안 함
Tree □□□□□□□ 0 / 14 ← 아직 시작 안 함
Heap □□□□□□□ 0 / 3 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 582 78 660 $0.000060
2 938 111 1,049 $0.000091
3 1,292 198 1,490 $0.000144
4 1,752 243 1,995 $0.000185
합계 4,564 630 5,194 $0.000480

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search, Two Pointers
  • 설명: 정렬을 이용해 인접한 중복을 확인하는 방식으로, 인접 비교를 통해 중복 여부를 판단한다. 두 포인터처럼 연속 원소를 비교하는 흐름이 핵심이다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 3가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: Solution.containsDuplicate — Time: ✅ O(nlogn) → O(n log n) / Space: ✅ O(1) → O(1)
유저 분석 실제 분석 결과
Time O(nlogn) O(n log n)
Space O(1) O(1)
풀이 2: unknown — Time: ? / Space: ?
복잡도
Time ?
Space ?
풀이 3: unknown — Time: ? / Space: ?
복잡도
Time ?
Space ?

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Comment thread house-robber/njngwn.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming, Greedy
  • 설명: 코드는 각 집의 금액을 스킵하며 최대 이익을 누적해 최댓값을 구하는 전형적인 DP 방식이다. 연속된 두 지점의 상태를 비교해 최적해를 갱신하는 점에서 DP의 공식을 따른다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Sorting
  • 설명: 코드에서 nums를 정렬하고 중복 제거 후 연속된 수의 길이를 스캔하여 최댓값을 구하므로 정렬 기반의 접근으로 분류됩니다. 패턴 목록에 정확히 매칭되는 항목은 'Sorting'이지만 목록에 있지 않으면 빈 배열이 될 수 있습니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Bucket / Counting Sort, Greedy
  • 설명: 두 솔루션 모두 원소의 빈도수를 해시 맵으로 세고(해시 맵), Solution 2에서는 카운트별 버킷 배열을 만들어 빈도에 따른 분류를 수행한다. 이를 통해 Top-K를 얻는 방식은 해시 맵 + 버킷 정렬의 아이디어에 해당한다.

Comment thread two-sum/njngwn.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Sort
  • 설명: 배열 정렬 후 인접한 중복 여부를 확인하는 방식으로, 직접적인 패턴 목록에는 없지만 배열 정렬을 이용한 중복 탐지는 흔한 기법이다. 이 코드에선 정렬 후 인접 비교로 중복 여부를 판단한다.

@njngwn njngwn moved this from Solving to In Review in 리트코드 스터디 8기 Jun 27, 2026

@namuuCY namuuCY left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

한주동안 고생하셨습니다!

Comment on lines +1 to +11
class Solution:
# Time Complexity: O(nlogn), n: len(nums)
# Space Complexity: O(1)
def containsDuplicate(self, nums: List[int]) -> bool:
nums.sort() # O(nlogn)

for i in range(len(nums)):
if i > 0 and nums[i] == nums[i - 1]:
return True

return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

안녕하세요!
공통적으로 같이 푼 문제들부터 순서대로 리뷰를 드리겠습니다!

저는 다른 방식으로 풀었는데, 이 방식으로 정렬 후 인접 숫자끼리 같을 경우를 따져도 되겠다는 생각이 듭니다.
제 방식은 정렬없이 각 숫자를 순회하면서 set에 있는지 확인한 후 없으면 set에 집어넣고 있으면 true를 반환하는 식으로 풀이했습니다.

이러면 시간복잡도 O(n), 공간복잡도 O(n)이 나오는데
njngwn님의 풀이와 이렇게 비교해보니 trade-off가 명확한것 같네요

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

시간복잡도를 고려했을 때, set을 이용한 것도 좋은 방법이네요! 감사합니다!


nums = sorted(set(nums)) # O(nlogn)
longest = 1
length = 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

length 보다 좀 더 명확하게 변수명을 설정하는건 어떨까요?

Comment on lines +9 to +14
counter = {}
for num in nums:
counter[num] = counter.get(num, 0) + 1
sorted_nums = sorted(counter, key=lambda num: counter[num])

return sorted_nums[-k:]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dict의 value순 정렬하고, k개 뽑을때 파이썬 문법을 사용해서 깔끔하게 잘 마무리하신것 같습니다!

@njngwn njngwn merged commit 37dd6e3 into DaleStudy:main Jun 27, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Review to Completed in 리트코드 스터디 8기 Jun 27, 2026
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