Skip to content

[freemjstudio] WEEK 03 Solutions#2734

Merged
freemjstudio merged 4 commits into
DaleStudy:mainfrom
freemjstudio:freemjstudio-week03
Jul 11, 2026
Merged

[freemjstudio] WEEK 03 Solutions#2734
freemjstudio merged 4 commits into
DaleStudy:mainfrom
freemjstudio:freemjstudio-week03

Conversation

@freemjstudio

@freemjstudio freemjstudio commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📊 freemjstudio 님의 학습 현황

이번 주 제출 문제

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

누적 학습 요약

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

문제 풀이 현황

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

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

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 1,023 191 1,214 $0.000128
2 1,464 204 1,668 $0.000155
3 1,463 199 1,662 $0.000153
4 1,785 200 1,985 $0.000169
합계 5,735 794 6,529 $0.000604

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
  • 설명: DFS-like 재귀로 후보를 탐색하며 조건에 맞으면 해를 저장하고, 선택 취소를 통해 모든 조합을 생성하는 전형적인 백트래킹 패턴입니다.

📊 시간/공간 복잡도 분석

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

피드백: 중복 조합 탐색을 막기 위해 start_idx를 유지하고, 같은 원소를 재사용 가능하게 하여 모든 조합을 생성한다.

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

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

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
  • 설명: 주어진 코드는 문자열을 한 글자/두 글자 조합으로 해석하는 방법을 DP 배열로 누적 카운트해 풀이합니다. 두 자리 조건을 확인해 부분문제를 합치며 최적해를 구하는 DP 패턴이 핵심이며, 한 자리 부분은 이전 상태를 더하는 형태로 구성됩니다.

📊 시간/공간 복잡도 분석

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

피드백: 연속된 두 자리 해석 여부를 체크하고, 한 자리 해석 가능 여부에 따라 dp 값을 누적한다.

개선 제안: 초기 입력 문자열의 길이가 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming
  • 설명: 연속 부분 배열의 최대 합을 부분 문제로 나누어 dp[i]를 i에서 끝나는 부분 배열의 최대 합으로 정의하고, 이전 상태와의 결정식으로 최적해를 구하는 대표적 DP 패턴이다.

📊 시간/공간 복잡도 분석

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

피드백: 현재 구현은 각 i에 대해 dp[i]를 갱신하고 최댓값을 필요시마다 반환한다.

개선 제안: 최적화하려면 extra 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Bit Manipulation, Greedy, Divide and Conquer
  • 설명: 주어진 코드는 정수의 이진 표현에서 1의 개수를 세는 문제로, 비트 조작 또는 나눗셈을 이용해 1의 비트를 카운트합니다. 비트 연산의 직관적 접근인 Bit Manipulation 패턴에 해당하며, 두 번째 구현은 반복적으로 각 자릿수를 확인하는 방식으로도 1의 비트를 셈.

📊 시간/공간 복잡도 분석

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

피드백: 첫 번째 구현은 파이썬 내장 함수로 간단하고 두 번째는 비트 연산으로도 가능하다.

개선 제안: 비트 카운트 최적화를 위해 Brian Kernighan의 알고리즘을 사용할 수 있다.

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

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, Binary Search, Hash Map / Hash Set
  • 설명: 문자열 전처리 후 좌우 포인터를 이용해 대칭 비교하는 방식으로 팰린드롬 여부를 판단합니다. 두 포인터가 중앙을 향해 움직이며 일치 여부를 확인하는 패턴입니다.

📊 시간/공간 복잡도 분석

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

피드백: 문자집합과 필터링 순서를 정의해 대소문자 무시 및 숫자 필터링을 수행한다.

개선 제안: 필터링과 비교를 한 번의 루프로 합치면 상수 공간으로 개선 가능하다.

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

@jthw1005 jthw1005 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.

이번주도 고생하셨습니다! 다음주도 화이팅입니다! 🔥

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.

생각도 안 하고 바로 DP로 풀었는데, 백트래킹 방식이 정배인거 같네요! 👍

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 로도 풀수있군용..

Comment on lines +2 to +4
def hammingWeight(self, n: int) -> int:
binary = bin(n)
return binary.count("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.

Hamming Weight이 뭘까하고 찾아봤는데, 상황에 딱 맞는 네이밍이네요.
하나 또 배워갑니다! 🙏


filtered = ""
for ch in s:
if ch in characters:

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.

문제 조건에서 s가 ascii로 제한되어 있으니 isalnum()을 쓰는 것도 괜찮을 것 같아 보이네요!

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.

오 그런 함수가 있군요 감사합니다!!

@freemjstudio freemjstudio merged commit 5005c96 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