Open
Conversation
huyfififi
approved these changes
Jul 2, 2025
| amount_to_num_coins[new_total] = min( | ||
| amount_to_num_coins[new_total], amount_to_num_coins[total] + 1 | ||
| ) | ||
| if math.isinf(amount_to_num_coins[amount]): |
Fuminiton
reviewed
Jul 3, 2025
| - 確かに。この観点はないといけない。 | ||
| - https://github.com/TORUS0818/leetcode/pull/42/files#r1904039471 | ||
| - Generator を使う方法。書き方の幅としてはまだまだ全然見えてないなと感じた。 | ||
| - 今回の複雑さであれば、初期値 inf でも許容する方針とした。 |
There was a problem hiding this comment.
あとは、X枚で作れる金額を列挙していき、amountと一致したらXを返すようなBFSでも実装できますね。
| if math.isinf(amount_to_num_coins[amount]): | ||
| return -1 | ||
| return amount_to_num_coins[amount] | ||
| ``` |
hroc135
reviewed
Jul 20, 2025
| ) | ||
| if math.isinf(amount_to_num_coins[amount]): | ||
| return -1 | ||
| return amount_to_num_coins[amount] |
There was a problem hiding this comment.
amount_to_num_coins[-1] と書くこともできますが、自分も amount とした方が好みです。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This Problem
322. Coin Change
Next Ploblem
35. Search Insert Position
言語: Python