Problem :

https://www.hackerrank.com/challenges/coin-change/problem


My Solution :

#!/usr/bin/env python3

def getWays(n, c):
    dp = [1 if x == 0 else 0 for x in range(n + 1)]
    for coin in c:
        for i in range(coin, n + 1):
            dp[i] += dp[i - coin]
    return dp[n]


n, m = map(int, input().strip().split())
c = map(int, input().strip().split())
print(getWays(n, c))