Skip to content

[Chaewon-Park-STUDY] WEEK 04 Solutions - #2966

Open
Chaewon-Park-STUDY wants to merge 14 commits into
DaleStudy:mainfrom
Chaewon-Park-STUDY:week4
Open

Chaewon-Park-STUDY wants to merge 14 commits into
DaleStudy:mainfrom
Chaewon-Park-STUDY:week4

Conversation

@Chaewon-Park-STUDY

@Chaewon-Park-STUDY Chaewon-Park-STUDY commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@dalestudy

dalestudy Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI 리뷰(알고리즘 패턴, 시간/공간 복잡도, 학습 현황) 결과는 Checks 탭에서 볼 수 있어요.



# 풀이1) (다른 풀이 더 고민 예정)
#Time:O(n+m),Space:O(n+m) n:list1의 노드의 개수 m:list2의 노드 갯수

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.

두 리스트가 이미 정렬되어 있다는 점을 활용해 head끼리 비교하고, 작은 값부터 병합하는 아이디어가 좋았습니다. 시간 및 공간 복잡도 분석도 맞는 것 같습니다.
또한, 이 부분 역시 Space Optimisation에서의 큰 원리와도 어느 정도 맞습니다.

현재는 answer 배열에 모든 노드의 값을 저장한 뒤, 새로운 ListNode를 생성하고 있는데요.
혹시 별도의 배열에 값을 저장하지 않고, 비교하는 시점에 기존 ListNode의 next 참조를 직접 연결하는 방식으로 구현할 수 있을까요?
기존 병합 아이디어를 그대로 유지하면서도 추가 공간 복잡도를 O(1)까지 줄일 수 있을 것 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

리뷰 감사합니다! 🙂
저도 다른 효율적 풀이가 있을 것 같아 고민해보려고 하였는데, 말씀해 주신 것처럼 값을 따로 저장하지 않고 비교하는 시점에 기존 노드의 next를 직접 연결하는 방식으로 풀어보겠습니다:)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

확실히 노드 간 연결로 코드를 수정하니 굉장히 간결해지네요~!

@Chaewon-Park-STUDY Chaewon-Park-STUDY moved this from Solving to In Review in 리트코드 스터디 9기 Dec 5, 2026

@parkhojeong parkhojeong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수고하셨습니다! 몇가지 커멘트 남겼습니다~

Comment thread word-search/Chaewon-Park-STUDY.py Outdated
Comment on lines +14 to +19
for i in range(m):
for j in range(n):
if board[i][j] != word[0]:
continue
stack = []
stack.append((i, j, 0, {(i, j)})) # (x, y, index, 지금 경로에서 지나온 칸들)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

stack에 i, j, index 이 들어가서 index 하고 i 하고의 차이점이 겹치는 거 같습니다.
row/column의 r, c, index 나 i, j word_index 처럼 구분이 되면 좋을 거 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

감사합니다:)
i, j는 그대로 두고 index를 word_idx로 바꿔서 board 좌표와 구분했습니다!

Comment thread word-search/Chaewon-Park-STUDY.py Outdated
m, n = len(board), len(board[0])

def in_range(x, y):
return 0 <= x and x < m and 0 <= y and y < n

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

0 <= x < m 으로 줄여서 써도 될 거 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

제가 코드트리에서 풀던 습관이 있어서 이렇게 분류해서 썼네요.. 한번에 합쳤습니다!

Comment thread word-search/Chaewon-Park-STUDY.py Outdated
for k in range(4):
nx, ny = x + dxs[k], y + dys[k]
if in_range(nx, ny) and (nx, ny) not in path and board[nx][ny] == word[index + 1]:
stack.append((nx, ny, index + 1, path | {(nx, ny)})) # 갈림길마다 새 집합

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

현재는 새로운 경로를 탐색할 때마다 집합을 복사하고 있어 추가적인 시간 및 공간 비용이 발생하는데요. 이 부분을 개선할 수 있는지 고민해 보시면 좋을 거 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

다른 분 풀이에서 비슷하게 본 것 같은데 좀 더 고민해보고 수정하겠습니다 ㅎㅎ
감사합니다

Comment thread coin-change/Chaewon-Park-STUDY.py Outdated
Comment on lines +8 to +11
for i in range(1, amount + 1):
for elem in coins:
if elem<=i: #현재 선택한 elem동전을 낼 수 있는 경우
dp[i]=min(dp[i],dp[i-elem]+1)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

연산자 피연산자 사이 공백을 일관되게 맞추는게 좋을 거 같습니다.

@Chaewon-Park-STUDY Chaewon-Park-STUDY Dec 5, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

피드백 감사합니다! 수정하겠습니다
공백 수정하는 김에 좀 더 명시적으로 드러내고자 elem도 coin으로 바꿨습니다

Comment on lines +7 to +9
while left<right:
mid=(left+right)//2
if nums[mid]>nums[right]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

이미 정렬된 구간에선 즉시 반환하는 최적화도 해보시면 좋을 거 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

while문에서 바로 시작할 때 이미 구간이 정렬되어있는지 체크하는 if문 추가했습니다!

Comment on lines +11 to +12
initial=ListNode() #고정
move=initial #이동

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

변수명을 의미를 나타나도록 조금 개선해보셔도 좋을 거 같습니다.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

dummy, last로 수정하였습니다~!

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.

3 participants