Skip to content

[seongmin36] WEEK 03 Solutions#2715

Merged
DaleSeo merged 5 commits into
DaleStudy:mainfrom
seongmin36:week3-solutions
Jul 12, 2026
Merged

[seongmin36] WEEK 03 Solutions#2715
DaleSeo merged 5 commits into
DaleStudy:mainfrom
seongmin36:week3-solutions

Conversation

@seongmin36

@seongmin36 seongmin36 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

📊 seongmin36 님의 학습 현황

이번 주 제출 문제

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

누적 학습 요약

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

문제 풀이 현황

카테고리 진행도 완료
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 794 122 916 $0.000089
2 2,399 238 2,637 $0.000215
합계 3,193 360 3,553 $0.000304

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
  • 설명: 정렬된 후보를 순차적으로 탐색하며 남은 합을 줄여가고, 조건이 맞으면 부분해를 결과에 추가하는 재귀 탐색 방식으로 구성되어 있어 Backtracking 패턴에 해당합니다.

📊 시간/공간 복잡도 분석

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

피드백: 오름차순 정렬 후 같은 원소를 여러 번 재사용하는 백트래킹 방식으로 해를 찾으며 가지치기를 통해 불필요한 경로를 줄인다.

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

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

Comment thread decode-ways/seongmin36.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, Two Pointers, Hash Map / Hash Set
  • 설명: 주어진 코드는 문자열 분할의 경우의 수를 DP로 계산한다. 총 2자리 또는 1자리 해석 가능 여부를 점진적으로 누적해 비용을 합산하는 바텀업 DP 패턴이 핵심이다. Two Pointers나 Hash Map보다는 DP의 중요 패턴이 가장 두드러진다.

📊 시간/공간 복잡도 분석

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

피드백: 두 자리 숫자 가능 여부를 isAlphabet로 판단하고 dp 배열에 누적해 경우의 수를 합산한다.

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

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

@seongmin36 seongmin36 moved this from Solving to In Review in 리트코드 스터디 8기 Jul 9, 2026

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
  • 설명: 코드는 Kadane의 알고리즘으로 연속 부분 배열의 합의 최댓값을 구한다. 현재 합이 음수면 새로운 시작점을 선택하고, 양수면 계속 확장하는 방식으로 최적해를 얻는다. 따라서 Greedy와 DP의 아이디어를 모두 포함하는 대표적 패턴이다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(1)

피드백: cur_sum과 result를 유지하며 음수 구간을 끊고 최대값을 갱신한다.

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

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

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
  • 설명: 비트 연산으로 1비트를 검사하고 우측으로 시프트하며 순차적으로 카운트하는 방식으로 최적화된 비트 조작 풀이이다. 덧붙여 숫자를 이진수로 변환하지 않고도 1의 개수를 구한다.

📊 시간/공간 복잡도 분석

복잡도
Time O(number of bits)
Space O(1)

피드백: n & 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
  • 설명: 문자열을 정규화한 뒤 양 끝에서 포인터를 이동시키며 비교하는 방식으로 회문 여부를 판단한다. 두 포인터를 동시에 움직이며 중앙으로 수렴하는 패턴이다.

📊 시간/공간 복잡도 분석

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

피드백: 입력 문자열을 정규화하고 양 끝에서 투포인터로 비교한다.

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

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

@togo26 togo26 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주차 수고하셨습니다👍

Comment thread decode-ways/seongmin36.js
if (isAlphabet(one_char)) {
dp[i] += dp[i - 1];
}
if (i >= 2) {

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.

로직 상 가장 위에서 0을 필터하기 때문에 첫번째 문자가 한가지 케이스라는 걸 보장합니다. 그래서 상단에 dp[1] = 1도 같이 초기화 할 수 있습니다. 그러면 루프 인덱스를 2로 시작할 수 있어 자연스럽게 i >= 2 삭제할 수 있습니다. (+ i 최대 범위도 조정해야 합니다)

Comment thread decode-ways/seongmin36.js
Comment on lines +34 to +35
let one_char = s.substring(i - 1, i);
let two_char = s.substring(i - 2, i);

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.

사소하지만 재할당이 없기 때문에 const 사용 가능합니다 :)

Suggested change
let one_char = s.substring(i - 1, i);
let two_char = s.substring(i - 2, i);
const one_char = s.substring(i - 1, i);
const two_char = s.substring(i - 2, i);

Comment on lines +17 to +21
if (cur_sum <= 0) {
cur_sum = nums[i];
} else if (cur_sum > 0) {
cur_sum = cur_sum + nums[i];
}

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.

이렇게 축약할 수 있을 것 같네요.

Suggested change
if (cur_sum <= 0) {
cur_sum = nums[i];
} else if (cur_sum > 0) {
cur_sum = cur_sum + nums[i];
}
cur_sum = Math.max(nums[i], cur_sum + nums[i]);

* @return {boolean}
*/
function isPalindrome(s) {
s = s.replace(/[^a-z0-9]/gi, "").toLowerCase();

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.

공간복잡도 관점에서 toLowerCase()는 내부적으로 문자열 길이만큼 새로운 문자열을 생성하기 때문에 문자열 n만큼 공간을 사용할 수 있습니다. 따라서 파라미터 값s 범위에 따라 현재 구현의 공간 사용은 선형적으로 증가하기 때문에 해당 메소드를 단일 문자열 검증에서 사용하면 복잡도를 상수로 낮출 수 있을 것 같습니다.

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

3 participants