Skip to content

[JeonJe] WEEK 03 Solutions#2713

Merged
JeonJe merged 5 commits into
DaleStudy:mainfrom
JeonJe:week3
Jul 11, 2026
Merged

[JeonJe] WEEK 03 Solutions#2713
JeonJe merged 5 commits into
DaleStudy:mainfrom
JeonJe:week3

Conversation

@JeonJe

@JeonJe JeonJe 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

📊 JeonJe 님의 학습 현황

이번 주 제출 문제

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

누적 학습 요약

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

문제 풀이 현황

카테고리 진행도 완료
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 336 46 382 $0.000035
2 632 92 724 $0.000068
3 1,047 207 1,254 $0.000135
4 1,441 232 1,673 $0.000165
5 1,785 238 2,023 $0.000184
합계 5,241 815 6,056 $0.000588

@JeonJe JeonJe moved this from Solving to In Review in 리트코드 스터디 8기 Jul 10, 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Backtracking, Depth-First Search
  • 설명: 깊이 우선 탐색으로 가능한 조합을 탐색하며, 후보를 하나씩 선택/삭제하는 백트래킹 방식이 핵심이다. 조건을 만족하면 답에 추가하고, 불가능하면 가지치기하며 재귀적으로 탐색한다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n^(target/min)) O(k * n)
Space O(target/min) O(n)

피드백: 각 재귀 단계에서 남은 타깃을 초과하지 않도록 가지치기를 하고, 같은 원소를 재사용하도록 인덱스를 i로 고정된 상태에서 재귀합니다.

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

Comment thread decode-ways/JeonJe.java

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
  • 설명: 문자열을 한 칸씩 보며 1자리/2자리 조합의 경우의 수를 누적합으로 계산하는 전형적인 계단 오르기/해석 문제 풀이로, 하위 문제의 해를 재활용하는 DP 패턴에 속합니다.

📊 시간/공간 복잡도 분석

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

피드백: 한 위치에 대해 한 자리와 두 자리를 고려하는 표준 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming
  • 설명: 배열의 부분배열 합의 최댓값을 구하기 위해 각 위치에서의 최댓값을 재귀적으로 계산하는 DP 패턴으로 구현되어 있다. 1차원 DP 배열을 활용해 중첩된 부분문제의 해를 저장한다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation, Greedy
  • 설명: 주어진 코드는 비트를 직접 다루며 1의 비트 수를 세는 로직으로, 비트 연산을 이용한 패턴(Bit Manipulation)을 사용합니다. 또한 매 턴 순서를 단순 반복하는 형태로 추가적인 최적화 없이 직접 비트를 확인합니다.

📊 시간/공간 복잡도 분석

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

피드백: 비트 단위 순회로 모든 비트를 검사해 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, Hash Map / Hash Set
  • 설명: 문자열에서 문자만 추출해 소문자로 정렬해 하나의 문자열(sb)로 만든 뒤 양 끝에서 각 인덱스의 문자를 비교하며 대칭 여부를 확인한다. 두 포인터로 중앙까지 진행하는 전형적인 Two Pointers 패턴과 문자열 전처리 관점의 간단한 최적화가 보인다.

📊 시간/공간 복잡도 분석

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

피드백: 전처리 문자열 빌더와 양 끝 비교로 대소문자 무시 및 알파벳/숫자만 검사

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

@seongmin36 seongmin36 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주차도 정말 고생많으셨고, 다음 4주차도 화이팅입니다! 😊

Comment on lines +10 to +12
if ((n & 1) == 1) {
answer++;
}

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 ((n & 1) == 1) {
answer++;
}
answer += n & 1;

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.

오호 ㅎㅎ +1, +0 으로도 작성이 가능하겠네요. 여기까진 미처 생각하지못했습니다 좋은 팁 감사합니다

Comment on lines +9 to +13
for (char c : s.toCharArray()) {
if (Character.isLetterOrDigit(c)) {
sb.append(Character.toLowerCase(c));
}
}

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.

우와, 문자를 배열로 나눠서 하나씩 비교하는 거군요. 내장함수 isLetterOrDigit()으로 쉽게 비교할 수 있는 방식인가보네요.. java는 뭔가 투박해보여도 꽤 친절한 언어인 것 같습니다!

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.

저도 이번 문제 풀면서 새로 알게 된 함수인데,
자바에도 이런 편리한 함수가 은근히 있는 것 같습니다 ㅎㅎ

answer = new ArrayList<>();

List<Integer> bucket = new ArrayList<>();
int curSum = 0;

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
int curSum = 0;

이 변수는 실제로 사용되지않는 데드코드인 것 같습니다. 없어도 될 것 같습니다!

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.

불필요 변수가 들어가버렸네요. 피드백 감사합니다!

Comment on lines +8 to +16
int[] dp = new int[n];

dp[n - 1] = nums[n - 1];
int answer = dp[n - 1];

for (int i = n - 2; i >= 0; i--) {
dp[i] = Math.max(dp[i + 1] + nums[i], nums[i]);
answer = Math.max(answer, dp[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.

직관적으로 잘 구현하신 것 같습니다. 여기서 SC를 O(1)로 최적화해볼 수 있을 것 같습니다.

현재 점화식이 참조중인 값이 이전값을 담는 것 하나라서 dp[] 대신에 int 변수를 사용해도(현재 상태 하나만으로도) 구현이 가능합니다!

Suggested change
int[] dp = new int[n];
dp[n - 1] = nums[n - 1];
int answer = dp[n - 1];
for (int i = n - 2; i >= 0; i--) {
dp[i] = Math.max(dp[i + 1] + nums[i], nums[i]);
answer = Math.max(answer, dp[i]);
}
int current_max = nums[n - 1];
int answer = current_max;
for (int i = n - 2; i >= 0; i--) {
current_max = Math.max(current_max + nums[i], nums[i]);
answer = Math.max(answer, current_max);
}

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.

오호 dp 배열이 아닌, 변수 두개로 공간복잡도를 최적화 할 수도 있겠네요.
다음 DP문제에 바로 적용해봐야곘습니다 감사합니다 👍

@JeonJe JeonJe merged commit a194811 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.

2 participants