Skip to content

[Chanz] WEEK 05 Solutions#2772

Open
Chanz82 wants to merge 5 commits into
DaleStudy:mainfrom
Chanz82:week-05
Open

[Chanz] WEEK 05 Solutions#2772
Chanz82 wants to merge 5 commits into
DaleStudy:mainfrom
Chanz82:week-05

Conversation

@Chanz82

@Chanz82 Chanz82 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📊 Chanz82 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
best-time-to-buy-and-sell-stock Easy ✅ 의도한 유형
encode-and-decode-strings Medium ✅ 의도한 유형
group-anagrams Medium ✅ 의도한 유형
implement-trie-prefix-tree Medium ✅ 의도한 유형
word-break Medium ⚠️ 유형 불일치

누적 학습 요약

  • 풀이한 문제: 12 / 75개
  • 이번 주 유형 일치율: 80% (5문제 중 4문제 일치)

문제 풀이 현황

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

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

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 1,812 250 2,062 $0.000191

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Greedy
  • 설명: 코드에서 두 포인터 buy와 sell를 이용해 한 번의 순회로 최적의 매수/매도 시점을 찾으며, 매번 현재 이익과 누적 최대 이익을 비교하는 방식은 Greedy와 Two Pointers의 결합 패턴에 속합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Greedy, Dynamic Programming, Hash Map / Hash Set, Two Pointers, Sliding Window, Backtracking, Divide and Conquer, Union Find, Trie, Bit Manipulation, Binary Search, Monotonic Stack, Heap / Priority Queue, BFS, DFS
  • 설명: 문자열을 길이와 구분자로 인코드/디코드하는 과정은 특정 패턴에 직접 대응되진 않지만, 문자열 순회와 분리 작업이 중심이다. 일반적으로는 문자열 조작/해시 기반 직렬화의 간단한 예로 볼 수 있으며, 특정 고전 알고리즘 패턴에 맞춘 명확한 패턴은 두드러지지 않는다.

📊 시간/공간 복잡도 분석

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

풀이 1: Solution.encode — Time: O(sum of lengths) / Space: O(1)
복잡도
Time O(sum of lengths)
Space O(1)

피드백: 각 문자열의 길이를 프리픽스로 붙여 구분하는 간단한 인코딩이다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: Solution.decode — Time: O(n) / Space: O(k)
복잡도
Time O(n)
Space O(k)

피드백: 세부 인덱스 추적을 통해 원래 문자열 목록을 회복한다.

개선 제안: 현재 구현이 적절해 보입니다.

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

Comment thread group-anagrams/Chanz82.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Sorting
  • 설명: 문자열을 정렬한 결과를 키로 사용해 같은 빈도(아나그램) 문자열을 그룹화하므로 해시 맵과 문자열 정렬 패턴이 적용됩니다. 정렬 키로 그룹핑하는 전형적 아나그램 풀이 방식입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n * m log m)
Space O(n * m)

피드백: 각 단어를 정렬한 결과를 키로 사용해 해시맵에 모은다.

개선 제안: 현재 구현이 적절해 보입니다.

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

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Trie, Hash Map / Hash Set
  • 설명: 트라이(Trie) 구조를 직접 구현하여 각 문자로 트리를 구성하고, 검색과 접두사 여부를 해시 맵 형태의 노드로 탐색합니다. 해시 맵은 자식 노드로 사용되며, 끝을 표시하는 구분자('#')를 통해 단어 완성 여부를 판단합니다.

📊 시간/공간 복잡도 분석

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

풀이 1: Trie.insert — Time: O(L) / Space: O(Total number of nodes)
복잡도
Time O(L)
Space O(Total number of nodes)

피드백: 해당 구현은 문자 코드(Key: ord) 기반으로 트라이를 구성한다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: Trie.search — Time: O(L) / Space: O( depth )
복잡도
Time O(L)
Space O( depth )

피드백: 종단 기호 존재 여부로 완전한 단어 여부를 확인한다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 3: Trie.startsWith — Time: O(L) / Space: O( depth )
복잡도
Time O(L)
Space O( depth )

피드백: 접두사 존재 여부만 확인하므로 빠르게 판별한다.

개선 제안: 현재 구현이 적절해 보입니다.

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

Comment thread word-break/Chanz82.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Backtracking, Dynamic Programming, Depth-First Search, Hash Map / Hash Set
  • 설명: DFS를 이용한 문자열 조합 시도와 방문 기록으로 중복 탐색을 제거하는 구조로, 백트래킹의 한 형태이며, 부분 문제를 재귀적으로 해결하는 동적 프로그래밍의 아이디어도 포함됩니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n * w)
Space O(n)

피드백: 백트래킹과 메모이제이션의 조합으로 부분 문제를 중복 없이 해결한다.

개선 제안: 현재 구현이 적절해 보입니다.

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

@ICE0208
ICE0208 self-requested a review July 25, 2026 10:59

@ICE0208 ICE0208 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

전체적으로 코드가 깔끔하게 작성되어 있어 흐름을 빠르게 이해할 수 있었습니다. 몇 가지 코멘트 남겨두었습니다. 이번 주도 고생 많으셨습니다! 🙌

Comment thread group-anagrams/Chanz82.py
Comment on lines +6 to +9
result = defaultdict(list)
for word in strs:
key = ''.join(sorted(word))
result[key].append(word)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

문자열이 lowercase English letters로 제한되어 있으므로, 정렬 방식 대신 알파벳 빈도 배열을 키로 사용하면 시간 복잡도를 더 줄일 수 있을 것 같습니다!

Comment on lines +8 to +16
search_map = self.root_map
while idx < len(word):
key = ord(word[idx])
if key not in search_map:
search_map[key] = dict()
search_map = search_map[key]
idx += 1
search_map['#'] = True

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

별도의 Node 클래스를 만들지 않고, 중첩된 dict 구조와 '#' 키를 활용해 단어의 끝을 판별한 점이 인상적이었습니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants