Your question is Minimum Coins Change. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Pinterest promotion credits can be represented using denominations such as whole-dollar coin values. Given an array of available coin denominations and a nonnegative credit amount, return the minimum number of coins required to make that amount. Each denomination may be used unlimited times. Return -1 if the amount cannot be formed.
Implement coin_change(coins, amount):
coins: a list of distinct positive integers representing available denominations.amount: a nonnegative integer representing the target credit amount.-1 when no combination produces amount.The order of coins does not matter, and using the same coin denomination multiple times is allowed.
def coin_change(coins, amount):