Skip to content

Add implementation for leetcode problems 198, 322#1977

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

Add implementation for leetcode problems 198, 322#1977
rishigoswamy wants to merge 1 commit intosuper30admin:masterfrom
rishigoswamy:master

Conversation

@rishigoswamy
Copy link

No description provided.

@super30admin
Copy link
Owner

Strengths:

  • The student has implemented the standard bottom-up dynamic programming solution correctly.
  • The time and space complexity are optimal.
  • The code is concise and easy to understand.

Areas for improvement:

  • The parameter name amounts should be changed to amount to match the problem statement and avoid confusion.
  • The documentation at the top of the file is incorrect: it describes the House Robber problem. This should be fixed to describe the Coin Change problem.
  • Adding inline comments to explain the dp array initialization and the inner loop would make the code more readable.
  • The return statement can be written as return dp[amounts] if dp[amounts] != amounts+1 else -1 instead of dp[-1] for clarity. Using dp[-1] is correct because it is the last element, but explicitly using dp[amounts] is more straightforward.

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