Skip to content

[Yiseull] WEEK 03 Solutions#2720

Merged
Yiseull merged 6 commits into
DaleStudy:mainfrom
Yiseull:main
Jul 12, 2026
Merged

[Yiseull] WEEK 03 Solutions#2720
Yiseull merged 6 commits into
DaleStudy:mainfrom
Yiseull:main

Conversation

@Yiseull

@Yiseull Yiseull commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

📊 Yiseull 님의 학습 현황

이번 주 제출 문제

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

누적 학습 요약

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

문제 풀이 현황

카테고리 진행도 완료
Array ■■■□□□□ 4 / 10 (Medium 2, Easy 2)
Heap ■■□□□□□ 1 / 3 (Medium 1)
Graph ■□□□□□□ 1 / 8 (Medium 1)
String ■□□□□□□ 1 / 10 (Easy 1)
Dynamic Programming ■□□□□□□ 1 / 11 (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 423 51 474 $0.000042
2 423 47 470 $0.000040
3 661 85 746 $0.000067
4 1,037 150 1,187 $0.000112
5 1,756 210 1,966 $0.000172
합계 4,300 543 4,843 $0.000432

(cherry picked from commit d881c4d)
@DaleSeo DaleSeo self-requested a review July 9, 2026 00:02

@DaleSeo DaleSeo 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 number-of-1-bits/Yiseull.java Outdated
@@ -0,0 +1,5 @@
class Solution {
public int hammingWeight(int n) {
return Integer.bitCount(n);

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.

옷, 요런 풀이는 출제 의도와 맞지 않을지도? 면접관이 Integer.bitCount이 어떻게 동작하는 깊고 파고 들면 인터뷰가 말릴 수도 있고요. 코딩 테스트에서 표준 라이브러리를 사용하는 것은 양날의 검이 될 수 있으니 참고 바랍니다.

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.

말씀하신 대로 코딩테스트 준비 과정에서는 라이브러리 사용을 자제하고 직접 구현해서 푸는 게 맞는 것 같습니다.
이 문제는 풀이를 알고 있어서 간단히 Integer.bitCount로 처리했는데, 앞으로는 내부 동작까지 설명할 수 있도록 직접 구현하는 방향으로 연습하겠습니다. 좋은 피드백 감사합니다! 🙏

@parkhojeong parkhojeong Jul 11, 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.

openjdk 구현체의 경우엔 2비트로 쪼개서 좌측 비트를 빼는 식으로 계산을 하네요. POPCNT 지원하는 cpu의 경우 JVM에서 체크해서 해당 명령어 사용하도록 최적화 하는 방식인 것 같습니다. 코드 링크도 첨부해드립니다~

https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/lang/Integer.java#L1594-L1614

    public static int bitCount(int i) {
        // HD, Figure 5-2
        i = i - ((i >>> 1) & 0x55555555);
        i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
        i = (i + (i >>> 4)) & 0x0f0f0f0f;
        i = i + (i >>> 8);
        i = i + (i >>> 16);
        return i & 0x3f;
    }

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.

코드까지 찾아서 알려주셔서 내부 구현 코드까지 확인했네요 감사합니다!👍 한 번에 이해는 안돼서 클로드랑 같이 이해 해봐야겠네요 ㅎㅎ

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(K * N)
Space O(N)

피드백: 정렬 후 가지치기를 통해 불필요한 경로를 제거하고, 현재 조합에 같은 원소를 재사용 가능하도록 인덱스 i를 유지한다.

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

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

Comment thread decode-ways/Yiseull.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(0/1 계단식) 문제 풀이 패턴이다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space 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
  • 설명: 최대 부분배열 문제를 한 루프에서 누적합과 부분해를 비교하는 방식으로 해결하므로 그리디 패턴에 속하며, 부분합의 최댓값을 유지하는 점에서 DP의 최적 부분구조 아이디어와도 연관된다.

📊 시간/공간 복잡도 분석

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

피드백: 현재 풀이에서 tmp를 누적하고 최댓값을 갱신하는 표준 방식이다.

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

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

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
  • 설명: 주어진 코드는 비트 연산을 이용해 1비트의 개수를 세는 방식이다. n & (n-1) 연산으로 최하위 1을 제거하는 트릭은 비트 조작 패턴의 대표 예이다.

📊 시간/공간 복잡도 분석

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

피드백: n & (n-1) 트릭으로 1비트를 제거하며 반복한다.

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

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

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

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Greedy, Hash Map / Hash Set
  • 설명: 주 코드의 두 번째 풀이에서 좌우 포인터를 이동하면서 문자 필터링 및 대소문자 비교를 통해 회문 여부를 판단한다. 필요한 경우 양쪽에서 각각 비교하며 조건에 맞지 않으면 즉시 반환하므로 투 포인터(좌우 포인터) 패턴에 해당한다. 필요 시 불필요 문자 건너뛰기 로직은 그리디적 흐름으로 진행된다.

📊 시간/공간 복잡도 분석

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

피드백: 2가지 구현 중 현재는 투 포인터 방식으로 추가 공간 없이 진행한다.

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

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

@parkhojeong parkhojeong 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 +3 to +12
int answer = -10001, tmp = 0;

for (int i = 0; i < nums.length; i++) {
tmp += nums[i];
answer = Math.max(answer, tmp);
tmp = Math.max(tmp, 0);
}

return 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.

tmp가 임시 변수로 의미 없는 값인 줄 알았는데 실제 로직에서는 의미가 있어서 적절한 네이밍 해주시면 더 좋을 거 같습니다!

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.

의미있는 네이밍 currentSum으로 변경했습니다! 피드백 감사합니다!

@Yiseull Yiseull merged commit 86d5e72 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