[Zero-1016] WEEK 03 Solutions#2708
Open
Zero-1016 wants to merge 6 commits into
Open
Conversation
Contributor
|
Contributor
📊 Zero-1016 님의 학습 현황이번 주 제출 문제
누적 학습 요약
문제 풀이 현황
🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다. 🔢 API 사용량 (gpt-5-nano)
|
namuuCY
approved these changes
Jul 5, 2026
namuuCY
left a comment
Contributor
There was a problem hiding this comment.
안녕하세요! 이번 주차 리뷰를 맡게된 장철영이라고 합니다.
우선 현재 푸신 문제까지 리뷰를 남겨놨고,
나머지 문제들 업데이트되면 추가 리뷰 드리도록 하겠습니다!
| * 시간 복잡도 O(N) | ||
| * 공간 복잡도 O(1) | ||
| */ | ||
| function hammingWeight2(n: number): number { |
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
- 패턴: Backtracking, Dynamic Programming, Greedy, Divide and Conquer, Hash Map / Hash Set
- 설명: 두 함수 모두 후보를 탐색하고 조건에 맞는 경로를 재귀적으로 구성하는 백트래킹 패턴을 사용합니다. 최적화 버전은 시작 인덱스 고정으로 중복 방문을 피하는 기법과 가지치기를 통해 탐색 공간을 축소합니다. 다만 실제로는 백트래킹이 중심이며, 결과 처리에서 중복 제거에 Set을 사용하는 점이 보조적으로 나타납니다.
📊 시간/공간 복잡도 분석
ℹ️ 이 파일에는 2가지 풀이가 포함되어 있어 각각 분석합니다.
풀이 1: combinationSum1 — Time: O(2^n) / Space: O(D)
| 복잡도 | |
|---|---|
| Time | O(2^n) |
| Space | O(D) |
피드백: 중복 순열 탐색으로 인해 불필요한 탐색이 많아 지수적 시간 복잡도가 증가합니다.
개선 제안: 고려해볼 만한 대안: start 인덱스를 도입해 중복 순열을 제거하고, 후보를 정렬한 뒤 가지치기를 적용하면 시간 복잡도를 크게 줄일 수 있습니다.
풀이 2: combinationSum2 — Time: ❌ O(nᴰ × D) → O(2^n) / Space: ❌ O(D + 정답 개수 × D) → O(D)
| 유저 분석 | 실제 분석 | 결과 | |
|---|---|---|---|
| Time | O(nᴰ × D) | O(2^n) | ❌ |
| Space | O(D + 정답 개수 × D) | O(D) | ❌ |
피드백: 정렬과 시작 인덱스 도입으로 중복 탐색을 막고, 남는 값을 빠르게 단절하는 가지치기 방식이 효과적입니다.
개선 제안: 현재 구현이 적절해 보입니다.
💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
- 패턴: Dynamic Programming, Two Pointers
- 설명: 해당 코드는 입력 문자열을 한 자리/두 자리로 나눠 해석하는 방법으로, dp[i]를 이용해 가능한 해를 누적합산한다. 변수 prev2, prev1로 최적화된 공간 복잡도 O(1) DP 패턴이며, 부분 문제를 합쳐 전체 해를 구하는 특징이 있다.
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
- 패턴: Greedy, Dynamic Programming
- 설명: 연속 부분 배열의 합을 한 번에 최대화하는 Kadane 알고리즘으로, 현재 구간의 합과 전체 최댓값을 갱신하는 그리디/동적 프로그래밍의 조합 패턴입니다.
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
- 패턴: Bit Manipulation
- 설명: 두 함수 모두 비트 연산으로 1의 비트 개수를 구한다. 비트마스크와 비트 시프트를 활용하는 대표적 비트 조작 기법으로 분류된다.
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
- 패턴: Two Pointers, Greedy
- 설명: 두 포인터(left, right)를 이용해 문자열을 양쪽에서 비교하며 조건에 맞지 않으면 건너뛰고, 같으면 이동하는 방식으로 팰린드롬 여부를 판단한다. 추가로 불필요한 문자 제거를 동반한 최적화로 O(N) 시간, O(1) 공간을 달성한다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!