Skip to content

[liza0525] WEEK 11 Solutions#2603

Merged
liza0525 merged 6 commits into
DaleStudy:mainfrom
liza0525:main
May 16, 2026
Merged

[liza0525] WEEK 11 Solutions#2603
liza0525 merged 6 commits into
DaleStudy:mainfrom
liza0525:main

Conversation

@liza0525
Copy link
Copy Markdown
Contributor

답안 제출 문제

1주차 문제지만 지금이라도 풀어봤습니다..!

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy
Copy link
Copy Markdown
Contributor

dalestudy Bot commented May 15, 2026

📊 liza0525 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
binary-tree-maximum-path-sum Hard ✅ 의도한 유형
graph-valid-tree Medium ✅ 의도한 유형
merge-intervals Medium ✅ 의도한 유형
missing-number Easy ⚠️ 유형 불일치
reorder-list Medium ✅ 의도한 유형
top-k-frequent-elements Medium ⚠️ 유형 불일치

누적 학습 요약

  • 풀이한 문제: 49 / 75개
  • 이번 주 유형 일치율: 67% (6문제 중 4문제 일치)

문제 풀이 현황

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

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

🔢 API 사용량 (gpt-4.1-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 3,425 209 3,634 $0.000426

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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search
  • 설명: 이 코드는 후위 탐색(DFS)을 사용하여 트리의 모든 경로를 탐색하며, 최대 경로 합을 계산하는 방식입니다. 재귀 호출로 트리의 하위 노드들을 방문하는 구조입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(h) O(h)

피드백: 전체 노드를 한 번씩 방문하는 후위 탐색을 수행하며, 재귀 호출 스택은 트리 높이만큼 쌓입니다. 노드 방문은 한 번이므로 시간 복잡도는 O(n), 재귀 스택은 최악의 경우(편향 트리) O(n), 평균적으로 O(log 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: DFS
  • 설명: 이 코드는 그래프의 연결성과 사이클 유무를 DFS 재귀 탐색으로 검사하여 트리 여부를 판단합니다. 방문 체크와 재귀 호출을 통해 깊이 우선 탐색을 수행하는 구조입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(V + E) O(V + E)
Space O(V + E) O(V + E)

피드백: 모든 노드와 엣지를 탐색하며, 방문 여부를 체크하는 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, Sorting
  • 설명: 이 코드는 정렬 후 두 포인터를 이용해 겹치는 구간을 병합하는 방식으로 문제를 해결합니다. 정렬과 두 포인터를 활용한 범위 병합이 핵심 패턴입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n log n) O(n log n)
Space O(1) O(n)

피드백: 정렬에 O(n log n), 병합 과정은 한 번의 순회로 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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Math
  • 설명: 이 코드는 수학적 공식을 이용하여 누락된 숫자를 찾는 방식으로, 수학적 계산을 활용하는 패턴입니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(1) O(1)

피드백: 전체 합 계산과 리스트 합산으로 각각 O(n), 전체적으로 O(n). 공간은 상수입니다.

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

Comment thread reorder-list/liza0525.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.

🏷️ 알고리즘 패턴 분석

  • 패턴: Fast & Slow Pointers, Reverse Linked List, Linked List Manipulation
  • 설명: 이 코드는 fast & slow 포인터를 사용해 리스트의 중간을 찾고, 뒤쪽 절반을 뒤집은 후 노드를 교차 연결하는 방식으로 리스트를 재구성합니다. 이 과정은 링크드 리스트 조작과 관련된 패턴을 포함합니다.

📊 시간/공간 복잡도 분석

유저 분석 실제 분석 결과
Time O(n) O(n)
Space O(1) O(1)

피드백: 중간 노드 찾기, 리스트 뒤집기, 병합 모두 리스트를 한 번씩 순회하므로 시간 복잡도는 O(n). 공간은 포인터 변수만 사용하여 O(1).

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

@@ -0,0 +1,23 @@
from collections import defaultdict
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.

1주차 문제입니다만.. 언젠간 꼭 풀겠다 생각하면서 이번주차에라도 풀어봤습니다..!

@reeseo3o reeseo3o self-requested a review May 16, 2026 13:09
Copy link
Copy Markdown
Contributor

@reeseo3o reeseo3o left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~!

class Solution:
def validTree(self, n: int, edges: List[List[int]]) -> bool:
visited = [0 for _ in range(n)]
node_map = defaultdict(list) # 노드 연결 정보 저장할 mapper
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 +13 to +31
i, j = 0, 1
res = []

# intervals를 탐색하는 i가 그 길이보다 작을 때 loop를 돈다
while i < len(intervals):
curr_start, curr_end = intervals[i] # 첫번째 머지 대상을 기준으로
while j < len(intervals): # j번째 요소들을 계속 머지함(범위 머지가 가능한 한)
next_start, next_end = intervals[j]
if curr_start <= next_start <= curr_end: # 다음 요소의 첫번째 값이 현재 요소 범위 내에 있을 때
curr_end = max(curr_end, next_end) # 더 큰 범위로 머지
else: # 그렇지 않으면 이번 텀에서의 머지가 완료된 것이므로 loop 탈출
break
j += 1 # 머지가 가능한 한 j를 계속 올려준다.

res.append([curr_start, curr_end]) # 머지 완료된 구간은 res에 담고
i = j # 이번 loop에서 사용했던 j가 다음 루프의 i가 되고
j = i + 1 # j는 i의 다음 인덱스부터 다시 머지를 할 수 있도록 변경

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

정렬 후 두 포인터로 겹치는 구간 확장하는 구조가 직관적이라 이해하기 좋았어요!

@liza0525
Copy link
Copy Markdown
Contributor Author

고생하셨습니다~!

@reeseo3o 감사합니다~ 다음주도 화이팅입니다!!

@liza0525 liza0525 merged commit 58baa94 into DaleStudy:main May 16, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Completed in 리트코드 스터디 7기 May 16, 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