Skip to content
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

Fix coin change #2571

Merged
merged 12 commits into from Oct 23, 2020
@@ -7,20 +7,23 @@
"""


def dp_count(S, m, n):
def dp_count(S, n):
"""
>>> dp_count([1, 2, 3], 3, 4)
>>> dp_count([1, 2, 3], 4)
4
>>> dp_count([1, 2, 3], 3, 7)
>>> dp_count([1, 2, 3], 7)
8
>>> dp_count([2, 5, 3, 6], 4, 10)
>>> dp_count([2, 5, 3, 6], 10)
5
>>> dp_count([10], 1, 99)
>>> dp_count([10], 99)
0
>>> dp_count([4, 5, 6], 3, 0)
>>> dp_count([4, 5, 6], 0)
1
>>> dp_count([1, 2, 3], -5)
0
"""

if n < 0:
return 0
# table[i] represents the number of ways to get to amount i
table = [0] * (n + 1)

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.