Coin Changing Problem

Dynamic Programming

In this problem our goal is to make change for an amount using least number of coins from the available denominations.

Example

Say I went to a shop and bought 4 toffees. It cost me Rs. 4 in total. So, I gave Rs. 10 to the shopkeeper.

The shopkeeper had Rs. 1 coins, Rs. 2 coins and Rs. 5 coins with him.
Now, the goal is: The shopkeeper has to make change for Rs. 6 using least number of coins from the available denominations coins (1, 2 and 5)

Assumptions

The shopkeeper has enough number of coins for the mentioned denomination so that he can make changes.

Solving this problem

The shopkeeper will make change for an amount Rs. 6
So, we can write A = 6