A well-known Change-making problem, which asks
how can a given amount of money be made with the least number of coins of given denominations
for some sets of coins will yield an optimal solution by using a greedy algorithm (grab the highest value coin).
My question is why it leads to an optimal solution for the set of coins (e.g. 25, 10 , 5, 2, 1) but not for the set of coins (e.g. 10, 7, 2, 1)? For example the second set fails for 15 change. It yields to (10, 2, 2, 1) while the optimal solution is (7, 7, 1). What rule should govern the set of coins so that it provide an optimal solution?