-
-
Notifications
You must be signed in to change notification settings - Fork 195
[hi-rachel] Week 04 Solutions #1340
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
Conversation
class Solution: | ||
def coinChange(self, coins: List[int], amount: int) -> int: | ||
dp = [0] + [amount + 1] * amount | ||
|
||
for coin in coins: | ||
for i in range(coin, amount + 1): | ||
dp[i] = min(dp[i], dp[i - coin] + 1) | ||
|
||
return dp[amount] if dp[amount] < amount + 1 else -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hi-rachel 님 안녕하세요. 이번 주도 고생하셨습니다. 저는 문제를 풀 때 dp로 접근하는 것을 어려워하는 편이라서, 특히 dp 풀이법을 인상깊게 봤습니다. 다음 주도 파이팅하세요 💪
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그리고 전체적으로 풀이가 깔끔해서 나중에 공부할 때도 참고가 될 것 같습니다. 감사합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hi-rachel 님 안녕하세요. 이번 주도 고생하셨습니다. 저는 문제를 풀 때 dp로 접근하는 것을 어려워하는 편이라서, 특히 dp 풀이법을 인상깊게 봤습니다. 다음 주도 파이팅하세요 💪
@KwonNayeon 님 안녕하세요 :) 저만 dp가 어려운게 아니였군여ㅜㅜ 저도 dp 문제는 이해 안가는 문제들이 많아서 힘들었는데 다행히 이 문제는 알고달레의 설명을 보고 이해했습니다. 저도 못풀어서 알고달레 풀이를 참고했는데 자세한 풀이를 원하실 때 추천드립니다. 감사합니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 dp는 간단한 문제 아니면 응용하기 너무 어렵더라구요...😂 역시 알고달레 👍 정말 감사합니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 dp는 간단한 문제 아니면 응용하기 너무 어렵더라구요...😂 역시 알고달레 👍 정말 감사합니다!
@KwonNayeon dp + 재귀 + 백트래킹 넘나 어려워요.. 이번 스터디 끝날 때쯤에는 사고가 넓어져있길! 같이 파이팅합시다! 감사합니다.
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!