I understand how the greedy algorithm for the coin change problem (pay a specific amount with the minimal possible number of coins) works - it always selects the coin with t
Today,I solved question similar to this on Codeforces(link will be provided at then end). My conclusion was that for coin-change problem to get solved by Greedy alogrithm, it should statisfy following condition:-
1.On sorting coin values in ascending order, all values to the greater than current element should be divisible by the current element.
e.g. coins = {1, 5, 10, 20, 100}, this will give correct answer since {5,10, 20, 100} all are divisible by 1,{10,20, 100} all are divisible by 5,{20,100} all are divisible by 10,{100} all are divisible by 20.
Hope this gives some idea.
996 A - Hit the lottery https://codeforces.com/blog/entry/60217