Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
326 B
3
Indexable
Never
#User function Template for python3
class Solution:
    def minCoins(self, coins, M, V):
        # code here
        ways=[0]+[float("inf")]*V
        for coin in coins:
            for i in range(coin,V+1):
                ways[i]=min(ways[i],(ways[i-coin]+1))
        
        return ways[V] if ways[V]!=float("inf") else -1