Nikzy7 / Algorithm-Snippets

Repo containing snippets of popular algorithms
17 stars 36 forks source link

coin change problem create #83

Closed Adil-S786 closed 4 years ago

Adil-S786 commented 4 years ago

sorry for the inconvenience, actually i am super new to this platform so i need your help and motivation😇.

On Thu, 8 Oct 2020 at 10:39, Apoorv Negi notifications@github.com wrote:

@Nikzy7 requested changes on this pull request.

Please provide the problem description and solution as comments in the code 😄

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Nikzy7/Algorithm-Snippets/pull/83#pullrequestreview-504432083, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQ7JIC2RXV6BVEIFT2U5D7TSJVCP7ANCNFSM4SHVNIMQ .

Adil-S786 commented 4 years ago

According to the coin change problem, we are given a set of coins of various denominations. Consider the below array as the set of coins where each element is basically a denomination. {1,2,3,4} Our task is to use these coins to accumulate a sum of money using the minimum (or optimal) number of coins. Also, we can assume that a particular denomination has an infinite number of coins. In other words, we can use a particular denomination as many times as we want.

For example, if we have to achieve a sum of 7 using the above denominations, we need the below 2 coins

But if we use the greedy technique it will give us 3 coins.

So above question shows us this through example if we take 15 as our total money, to get 4 coins.