Skip to content

[Chanz] WEEK 02 Solutions#2695

Open
Chanz82 wants to merge 11 commits into
DaleStudy:mainfrom
Chanz82:main
Open

[Chanz] WEEK 02 Solutions#2695
Chanz82 wants to merge 11 commits into
DaleStudy:mainfrom
Chanz82:main

Conversation

@Chanz82

@Chanz82 Chanz82 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

Chanz82 added 11 commits June 26, 2026 01:17
Implement twoSum method to find indices of two numbers that add up to target.
Refactor two-sum solution to use a single loop for finding matches.
Implement isAnagram method to check if two strings are anagrams using a hashmap.
Implement memoization for climbing stairs problem.
Implement productExceptSelf method to calculate the product of array except self using two auxiliary lists.
@dalestudy

dalestudy Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

📊 Chanz82 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
climbing-stairs Easy ✅ 의도한 유형
product-of-array-except-self Medium ✅ 의도한 유형
valid-anagram Easy ✅ 의도한 유형

누적 학습 요약

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

문제 풀이 현황

카테고리 진행도 완료
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 ← 아직 시작 안 함
Heap □□□□□□□ 0 / 3 ← 아직 시작 안 함

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

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 1,118 132 1,250 $0.000109

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, Memoization, Divide and Conquer
  • 설명: 해당 코드는 피보나치 계열의 점화식을 동적계획법으로 풀고, 중간 결과를 저장해 재계산을 피하는 형태로 작성되어 있습니다. 메모이제이션을 통해 중복 계산을 방지하며, 재귀 분할로 문제를 해결합니다.

📊 시간/공간 복잡도 분석

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

피드백: 각 n에 대해 한 번씩 계산하고 결과를 메모에 저장하므로 시간은 선형이며, 재귀 깊이는 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.

공간복잡도 맞긴 하신데, 재귀를 하면 메모리 스택에 Function call이 계속 쌓이기 때문에 배열을 쓰는것보단 좋진 않을거에요!

쉬운것부터 바텀업으로 구현하시는것도 저는 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.

아아 그러네요 스택 메모리도 감안을 해야 하는군요.. n이 커지면 메모리 점유가 엄청나게 많아지겠군요..!
좋은 인사이트 감사합니다!! 👍

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 앞에 피드백 주신 분과 같이 n이 커지면 recursion error가 날 수 도 있을 거 같아서 바텀업 구현을 고려해보시는 것도 좋을 거 같다는 의견입니다!

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, Dynamic Programming, Hash Map / Hash Set, Greedy, Divide and Conquer, Binary Search, Monotonic Stack, Breadth-First Search, Depth-First Search, Backtracking, Union Find, Trie, Bit Manipulation, Heap / Priority Queue
  • 설명: 주어진 해결책은 각 위치의 곱을 좌우 누적 곱으로 구하는 방식으로, 중간에 보조 배열(left, right)을 사용해 결과를 얻는 구조이다. 이는 배열 기반의 누적 결과를 이용하는 패턴으로, 난이도는 DP적 사고와 함께 부분 문제를 결합한다는 점에서 Dynamic Programming의 applying 형태로 해석할 수 있다.

📊 시간/공간 복잡도 분석

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

피드백: 추가 배열 left와 right를 사용해 각 원소에 대해 O(1) 추가 연산으로 결과를 얻는다.

개선 제안: 추가 공간 없이 결과 배열 하나만 사용하도록 압축 가능하다.

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

@alphaorderly alphaorderly Jul 3, 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.

Follow up 에 공간복잡도 O(1)로 해결해 보라는게 있어서요 ( 출력 배열 1개 제외 )

한번 시도해 보시는것도 좋을것 같아요!

힌트는 left, right 이 두개는 사실 배열이 아니여도 됩니다!

Comment thread valid-anagram/Chanz82.py

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Two Pointers
  • 설명: 두 문자열의 문자가 같은지 확인하기 위해 문자 빈도수를 해시맵으로 세고, t의 문자가 나타날 때마다 감소시키며 남은 개수를 확인합니다. 해시맵을 이용한 카운팅 방식은 패턴으로 분류되고, 두 문자열의 합치면서 비교하는 흐름이 포함되어 있어 두 패턴으로 간주합니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n + m)
Space O(k)

피드백: 두 문자열 길이에 비례하는 선형 시간과 알파벳 크기에 비례하는 공간을 사용한다.

개선 제안: 모든 문자가 ASCII인 경우 배열 인덱스 기반 구현으로 상수 공간에 근접 가능하다.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음에 string s랑 string t랑 길이가 다르면 반복문을 아예 돌지 않고 바로 false를 반환하는 base가 있으면 더 좋을 거 같아요!

@Chanz82 Chanz82 changed the title [Chanz [Chanz] WEEK 02 solutions Jul 3, 2026
@Chanz82 Chanz82 changed the title [Chanz] WEEK 02 solutions [Chanz] WEEK 02 Solutions Jul 3, 2026
@Hoonjichoi1 Hoonjichoi1 self-requested a review July 3, 2026 05:42

# 이미 계산 한 값이라면 반환
if n in self.memo:
return self.memo[n]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이미 계산했던 값인지 체크하고 바로 반환해 주는거 좋은 거 같아요!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저도 앞에 피드백 주신 분과 같이 n이 커지면 recursion error가 날 수 도 있을 거 같아서 바텀업 구현을 고려해보시는 것도 좋을 거 같다는 의견입니다!

Comment thread valid-anagram/Chanz82.py

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음에 string s랑 string t랑 길이가 다르면 반복문을 아예 돌지 않고 바로 false를 반환하는 base가 있으면 더 좋을 거 같아요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Solving

Development

Successfully merging this pull request may close these issues.

3 participants