Skip to content

[alphaorderly] WEEK 06 Solutions - #2777

Open
alphaorderly wants to merge 30 commits into
DaleStudy:mainfrom
alphaorderly:main
Open

[alphaorderly] WEEK 06 Solutions#2777
alphaorderly wants to merge 30 commits into
DaleStudy:mainfrom
alphaorderly:main

Conversation

@alphaorderly

@alphaorderly alphaorderly commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

📊 alphaorderly 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
container-with-most-water Medium ✅ 의도한 유형
design-add-and-search-words-data-structure Medium ✅ 의도한 유형
longest-increasing-subsequence Medium ✅ 의도한 유형
spiral-matrix Medium ✅ 의도한 유형
valid-parentheses Easy ✅ 의도한 유형

누적 학습 요약

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

문제 풀이 현황

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

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

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 2,644 249 2,893 $0.000232
2 2,644 196 2,840 $0.000211
3 2,634 222 2,856 $0.000220
합계 7,922 667 8,589 $0.000663

@JeonJe
JeonJe self-requested a review July 28, 2026 11:05
Comment thread valid-parentheses/alphaorderly.py Outdated
else:
stack.pop()

return len(stack) == 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.

return len(stack) == 0return not stack 으로 더 간단하게 써볼 수 있을 것
같습니다!

PEP 8 Programming Recommendations에서는 빈 컨테이너의 falsy를 그대로 쓰는 쪽이 권장
형태인 듯합니다. 저도 이번에 찾아보며 알게 된 거라 공유드립니다 🙂

For sequences, (strings, lists, tuples), use the fact that empty sequences are false:

# Correct:
if not seq:
if seq:

# Wrong:
if len(seq):
if not len(seq):

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.

맞아요! 배열, 셋 같은데 비어있는지 체크하는데 좋은 연산이죠.
해당 부분 수정했습니다!

if ch == '.':
for child in node.children.values():
search.append(child)
elif ch not in node.children:

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.

elif ch not in node.children:
    continue
else:
    search.append(node.children[ch])

케이스마다 동작을 명시하는 것도 좋고, continue가 아무런 동작을 하지 않으니 아래 처럼 줄여볼 수도 있을 것 같습니다!

elif ch in node.children:
    search.append(node.children[ch])

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.

맞네요, continue를 괜히 넣었군요
수정 했습니다!

node = node.children[ch]
node.end = True

def search(self, word: str) -> bool:

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.

BFS 순회는 생각 하지 못했는데 새롭게 배웠습니다!! 👍 👍 👍

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.

세상에 존재하는 거의 모든 DFS는 BFS로 접근할수 있는거 같더라고요, 물론 재귀 제외하면 DFS가 더 나은것같다는 직감이 들기는 합니다 ㅎㅎ

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
  • 설명: 두 포인터를 양 끝에서 시작해 더 작은 높이를 가진 쪽을 한 칸씩 이동시키며, 현재 면적과 이후 최댓값을 비교하는 방식으로 최적해를 찾는 구조로, 시간 복잡도는 선형이며 탐색 방향 결정이 탐욕적으로 처리됩니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n)
Space O(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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Trie, Backtracking, Depth-First Search, Breadth-First Search
  • 설명: 단어를 Trie로 저장하고 '.' 와일드카드에 대해 DFS/BFS 방식으로 탐색하는 구조로, 단어 추가는 트리 형태의 탐색/생성이며 와일드카드 탐색에서 DFS 또는 BFS를 사용할 수 있다. 따라서 Trie 기반의 탐색 문제에 해당하며 백트래킹 성질도 존재한다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 2가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: WordDictionary.addWord — Time: O(L) / Space: O(T)
복잡도
Time O(L)
Space O(T)

피드백: 단어의 길이 L에 비례하는 시간으로 노드를 생성하며 공간은 트라이 크기(T)에 비례한다.

개선 제안: 중복 파일의 두 구현 중 하나를 제거하고 하나의 명확한 구현으로 정리하면 좋습니다.

풀이 2: WordDictionary.search (BFS 버전) — Time: O(N) / Space: O(T)
복잡도
Time O(N)
Space O(T)

피드백: 와일드카드로 인해 최악의 경우 확장 가능 경로가 많아질 수 있지만 일반 탐색은 선형이다.

개선 제안: 두 구현 중 하나로 통일하고, 필요시 DFS 버전을 선택적으로 사용하도록 인터페이스를 간단히 한다.

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

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Binary Search, Greedy
  • 설명: 배열의 각 원소를 정렬된 배열의 삽입 위치를 이진 탐색으로 찾고, 필요 시 교체하는 방식은 LIS를 길이를 최소로 유지하는 그리디적 아이디어를 사용합니다. 또한 이진 탐색으로 삽입 위치를 찾는 것이 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

복잡도
Time O(n log 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Monotonic Stack, Backtracking, Greedy, Dynamic Programming, Hash Map / Hash Set, Two Pointers, Sliding Window, Fast & Slow Pointers, BFS, DFS, Divide and Conquer, Union Find, Trie, Bit Manipulation, Heap / Priority Queue, Binary Search
  • 설명: 주어진 코드는 격자에서 방향을 바꾸며 순회하는 spiral 탐색으로, 현재 위치를 방문하고 방문 여부를 표시한 뒤 경계와 방문 여부를 확인하며 진행하는 패턴이다. 목표는 모든 원소를 순차적으로 방문하기 위해 위치와 방향을 관리하는 로직으로 구성되어 있다.

📊 시간/공간 복잡도 분석

복잡도
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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Stack / Stack-based, Hash Map / Hash Set
  • 설명: 괄호 매칭 문제로 스택을 사용해 열려 있는 괄호를 기억하고, 닫는 괄호와 매칭 여부를 검사합니다. 해시 맵으로 괄호 쌍을 빠르게 찾는 구조도 포함되어 있습니다.

📊 시간/공간 복잡도 분석

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

피드백: 열린 괄호를 스택에 쌓고 닫을 때 매칭 여부를 확인한다.

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

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

Comment on lines +13 to +23
def lengthOfLIS(self, nums: List[int]) -> int:
arr = []

for num in nums:
position = bisect_left(arr, num)
if position == len(arr):
arr.append(num)
else:
arr[position] = num

return len(arr)

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.

굉장히 깔끔하게 푸셨네요!!

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

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants