Search code examples
cdynamiccoin-change

Which is a good algorithm for solving this algorithmic puzzle?


I am given an amount say $50. I am given some denominations say $1 ,$2 ,$5 etc. and the number of these denominations eg 1 ,5,6 that means 1 coin/note of $1 ,5 coins/notes of $2 and 6 coins/notes of $5. I have to find the number of ways these coins can be used to form this amount $50. I am trying to think an efficient algorithm to solve this in the fastest time possible. Please note here the amount will never exceed $60.

Can someone please suggest which algorithm I can use to solve this problem? Till now I have written a recursive solution for this problem but it is too slow for my purpose.I will be posting it here soon.


Solution

  • I agree that this is not the place for homework, but still... The asker does not expect to get solution, he is only asking for a direction. let's not keep questions open unecessarily

    Have a look at Integer factorization