Skip to content

[river20s] WEEK 05 solutions #1391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 3, 2025
Merged

[river20s] WEEK 05 solutions #1391

merged 10 commits into from
May 3, 2025

Conversation

river20s
Copy link
Contributor

@river20s river20s commented Apr 28, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@clara-shin clara-shin self-requested a review April 28, 2025 14:38
# 최대 이익 갱신
max_profit = max(max_profit, (price - min_price))
# 최소 가격 갱신
min_price = min(min_price, price)
Copy link
Contributor

Choose a reason for hiding this comment

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

"최소 이익 갱신 이후 최소 가격 갱신해야 함" 주석이 실제 코드 순서와 반대로 되어 있습니다.
코드에서는 최대 이익을 먼저 계산한 후 최소 가격을 갱신하고 있으므로, 주석과 맞게 조정하면 좋겠습니다 :)
전반적으로 매우 깔끔하고 효율적인 코드 같습니다. 고생하셨습니다👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

감사합니다. 반영하여서 수정했습니다!

river20s added 5 commits May 1, 2025 23:59
리뷰를 반영하여, 최대 이익(max_profit) 계산과 최소 가격(min_price) 갱신 순서를 설명하는 주석이 실제 코드와 반대로 되어 있던 오류를 수정했습니다.
코드에서 사용한 변수명을 주석에 함께 표기해 더 쉽게 읽히도록 했습니다.
- <139. Word Break> 문제에 대한 초기 접근 방식으로 재귀 호출과 트라이를 사용하여 구현함
- 트라이를 통해 딕셔너리 단어 검색 효율은 개선했으나 재귀 호출 과정에서 발생하는 중복 연산 문제로 인해 TLE 발생을 확인하였음
- 메모이제이션 또는 DP로 최적화 예정임
- 문제 이슈: DaleStudy#271
- 기존 재귀 + 트라이 방식에서 발생하던 TLE 문제를 해결하기 위해 메모이제이션을 사용하였음
- `canBreak(start_index)` 함수 결과를 `memo` 딕셔너리에 캐싱하여 동일한 `start_index`에 대한 중복 계산 방지
@river20s river20s merged commit 92e54ef into DaleStudy:main May 3, 2025
1 check passed
@github-project-automation github-project-automation bot moved this from Solving to Completed in 리트코드 스터디 4기 May 3, 2025
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