Skip to content

[togo26] WEEK 03 Solutions#2723

Merged
togo26 merged 20 commits into
DaleStudy:mainfrom
togo26:main
Jul 11, 2026
Merged

[togo26] WEEK 03 Solutions#2723
togo26 merged 20 commits into
DaleStudy:mainfrom
togo26:main

Conversation

@togo26

@togo26 togo26 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

📊 togo26 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
combination-sum Medium ✅ 의도한 유형
decode-ways Medium ✅ 의도한 유형
maximum-subarray Medium ✅ 의도한 유형
number-of-1-bits Easy ✅ 의도한 유형
valid-palindrome Easy ✅ 의도한 유형

누적 학습 요약

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

문제 풀이 현황

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

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

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 2,887 228 3,115 $0.000236
2 2,884 214 3,098 $0.000230
3 2,867 192 3,059 $0.000220
합계 8,638 634 9,272 $0.000686

@github-actions github-actions Bot added the js label Jul 9, 2026
@dahyeong-yun dahyeong-yun self-requested a review July 10, 2026 05:55
@togo26 togo26 changed the title [DaleSeo] WEEK 03 Solutions [togo26] WEEK 03 Solutions Jul 10, 2026

@dahyeong-yun dahyeong-yun 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.

실패 케이스까지 꼼꼼하게 적어주셔서 저도 공부가 많이 되었습니다! 3주차도 고생하셨어요 :)

* @return {number}
*/

// TLE

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 thread combination-sum/togo26.js
for (let i = start; i < candi.length; i++) {
const newAcc = acc + candi[i];
const newCombi = [...combi, candi[i]];
if (newAcc > target) break;

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 thread combination-sum/togo26.js
for (let i = start; i < candi.length; i++) {
const newAcc = acc + candi[i];
const newCombi = [...combi, candi[i]];
if (newAcc > target) break;

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 thread valid-palindrome/togo26.js Outdated
Comment thread decode-ways/togo26.js Outdated

// Log-based calculation
// TC: O(1) / SC: O(1)
// 비트 제약이 없을 경우 -> TC: O(logn) / SC: O(logn)

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.

덕분에 저도 자료형의 허용 범위 이상인 경우를 생각해봐야 한다는 걸 느꼈어요 👍🏼

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.

O(n³)부터 O(n²), O(n)까지 모든 풀이를 남겨주셔서 시간 복잡도가 개선되는 과정이 잘 보여 인상 깊었습니다!

togo26 and others added 2 commits July 12, 2026 01:35
Remove unnecessary regex construction

Co-authored-by: polymorph <33543196+dahyeong-yun@users.noreply.github.com>
Remove redundant code range validation

Co-authored-by: polymorph <33543196+dahyeong-yun@users.noreply.github.com>
Comment thread combination-sum/togo26.js

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, Depth-First Search, Greedy
  • 설명: 백트래킹으로 모든 조합을 탐색하고, 목표값(target)에 도달하면 해를 추가합니다. 오름차순 정렬 후 누적합이 target을 넘으면 더 탐색을 중단하는 가지치기(pruning)로 DFS를 사용합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(C^(T/m)) O(k * n^k)
Space O(T/m) O(target 깊이)

피드백: 정렬된 후보를 이용해 불필요한 경로를 조기에 차단하고, 같은 후보를 재사용하여 조합을 구성한다.

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

Comment thread decode-ways/togo26.js

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, Hash Map / Hash Set, Bit Manipulation
  • 설명: 문제는 문자열의 각 위치에서 한 글자 또는 두 글자를 해석해 경우의 수를 누적하는 DP 접근이다. memo 배열로 중복 계산을 피하는 구조가 DP의 핵심이며, 코드 맵은 dp 상태를 캐싱하기 위한 해시 맵을 활용한다.

📊 시간/공간 복잡도 분석

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

풀이 1: numDecodings — Time: ✅ O(n) → O(n) / Space: ✅ O(n) → O(n)
유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(n) O(n)

피드백: 가능한 한도에서 중복 부분 문제를 피하며 재귀 호출에 대한 결과를 저장한다.

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

풀이 2: numDecodings — Time: ✅ O(n) → O(n) / Space: ✅ O(n) → O(n)
유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(n) O(n)

피드백: 입력 문자열 길이에 따라 선형적으로 동작하며 중복 계산을 피한다.

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

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
  • 설명: 카데인 알고리즘으로 알려진 최대 부분 배열 문제 풀이로, 현재 값을 비교해 누적합을 업데이트하고 전체 최댓값을 갱신합니다. 이는 최적해를 한 번의 선형 순회로 얻는 Greedy + DP 성격의 패턴에 해당합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(n) 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation, Greedy, Divide and Conquer
  • 설명: 주 코드의 핵심은 이진수를 다루는 비트 연산(Bit Manipulation)을 통해 1의 개수를 구하는 패턴이다. 일부 구현은 로그 기반 탐색과 반복 감소로 구성되며, 대표적으로 비트를 제거하는 n & (n-1) 기법이 있다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(logn) O(1)
Space O(logn) 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Greedy
  • 설명: 두 포인터(left, right)를 사용해 문자열의 양쪽에서 비교하는 구간 탐색 방식이 핵심이며, 공통적으로 부분 문자열 비교를 통해 조건을 만족하는지 판단합니다. 또한 직접적인 최적화 없이 대칭 비교를 통해 문제를 해결하는 점에서 그리디적 기법과도 연결됩니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(n) O(1)

피드백: 정규식 제거/두 포인터 방식으로 불필요한 문자열 생성 없이 해결한다.

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

@togo26 togo26 merged commit 80e2e17 into DaleStudy:main Jul 11, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from In Review to Completed in 리트코드 스터디 8기 Jul 11, 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.

4 participants