Skip to content

Completed dp-1#1979

Open
shinjaneegupta wants to merge 1 commit intosuper30admin:masterfrom
shinjaneegupta:master
Open

Completed dp-1#1979
shinjaneegupta wants to merge 1 commit intosuper30admin:masterfrom
shinjaneegupta:master

Conversation

@shinjaneegupta
Copy link

No description provided.

@super30admin
Copy link
Owner

Your solution for the Coin Change problem is excellent. You have implemented the dynamic programming approach efficiently with O(m*n) time and O(n) space, which is optimal for this problem. Your code is clean and well-commented. The approach is correct and handles all edge cases.

One minor note: in the problem constraints, the coins can be as large as 2^31-1, but the amount is only up to 10^4. So, when iterating with each coin, if a coin is larger than the amount, it can be skipped to avoid unnecessary iterations. However, this is a minor optimization and does not change the overall complexity. For example, you could add a check before the inner loop to skip coins that are larger than the current target (but since the inner loop starts from the coin value, if the coin is larger than amount, the inner loop won't run anyway). So it's already handled.

Overall, great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants