Skip to content

2 Problems completed#1976

Open
BharathVuppala96 wants to merge 4 commits intosuper30admin:masterfrom
BharathVuppala96:master
Open

2 Problems completed#1976
BharathVuppala96 wants to merge 4 commits intosuper30admin:masterfrom
BharathVuppala96:master

Conversation

@BharathVuppala96
Copy link

No description provided.

@super30admin
Copy link
Owner

The student has implemented a dynamic programming solution that is generally correct (except for the initial check). The time complexity is optimal for a DP solution. However, there are a few issues:

  • The initial check should be: if amount==0, return 0. Then if coins is None or empty, and amount>0, return -1.
  • The condition inside the outer loop to check for -1 is placed incorrectly. It should be after the entire DP table is filled. Actually, the student checks at the end of each row, but only the last row matters. So it would be better to move the check outside the loops.
  • The code can be optimized in space by using a 1D array.

Also, the student submitted another solution for "House Robber", which is not relevant to this problem. We should only evaluate the "Coin Change" solution.

Given that the core DP

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