I'm learning the dynamic programming approach to solve the coins change problem, I don't understand the substitution part
Given: amount=9, coins = [6,5,1]
,
the instructor simplified it with this function:
minCoins = min {(9-6)+1 , (9-5)+1, (9-1) +1} = min{4, 5, 9} = 4
I don't understand the logic of this min
method: why we say that to change amount of 9 coins, we can simply, take the minimum of: 9 - {all coins} +1 ?
here's a Gif that visualizes the instructor's approach: https://i.stack.imgur.com/Zx2cG.gif
(*taken from the Algorithmic Toolbox course/ instructor: Prof. Pavel A. Pevzner)