Questions tagged [coin-change]

All problems (regardless of currency) with making change from a given amount of currency into a number of coins and bills of varying denominations.

All problems with making change from a given amount of currency into a number of coins and bills of varying denominations.

For example, finding the correct number of $20, $10, $5, $1 bills and $0.25, $0.10, $0.05, and $0.01 coins that add up to a given sum.

Variations of the problem are to find any solution, all the solutions, the one with the least number of coins / bills, or with a specific number of them.

260 questions
0
votes
0 answers

Coin change. Dynamic programming

I've found this algorithm online and it works, but I don't know why. Even though there is a video explaining it. Here is the code: public int numberOfSolutionsOnSpace(int total, int arr[]){ int temp[] = new int[total+1]; temp[0] = 1; …
Deividas
  • 79
  • 1
  • 9
0
votes
2 answers

Minimum number of coins for a given sum and denominations

Given a set of denominations and the sum required I have to find the minimum number of coins that make that sum and also the number of coins for each denominations Please help!!
0
votes
1 answer

Greedy Algorithm for coin change c++

So, I'm creating a coin change algorithm that take a Value N and any number of denomination and if it doesn't have a 1, i have to include 1 automatically. I already did this, but there is a flaw now i have 2 matrix and i need to use 1 of them. Is it…
Darkflame
  • 79
  • 2
  • 11
0
votes
2 answers

Get the quantity of bills and coins for any value

I want to make a little system that returns me the optimized quantity of bills and coins for any value. Here's my code for while: public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new…
developer033
  • 24,267
  • 8
  • 82
  • 108
0
votes
0 answers

coin change function using unbounded knapsack python

I'm trying to write a coin change function. The idea is that I have unlimited denominations and whatever value and trying to see what kind of change I can get. I thought this could be done like an unbounded knapsack program but I'm getting a weird…
0
votes
0 answers

Python Coin Change: Incrementing list in return statement?

Edit: Still working on this, making progress though. def recursion_change(available_coins, tender): """ Returns a tuple containing: :an array counting which coins are used to make change, mirroring the input array :the number…
0
votes
1 answer

Coin Change DP Algorithm Print All Combinations

The classic coin change problem is well described here: http://www.algorithmist.com/index.php/Coin_Change Here I want to not only know how many combinations there are, but also print out all of them. I'm using the same DP algorithm in that link in…
Arch1tect
  • 4,128
  • 10
  • 48
  • 69
0
votes
1 answer

Count all subsets with given sum - Java

I have an array list of distinct positive integers representing a set L, and an integer S. What's the fastest way to count all subsets of L which have the sum of their elements equal to S, instead of iterating over all subsets and just checking if…
0
votes
2 answers

maximum number of coins required to make change

I was trying to do this problem, where given coins of certain denomination, I want to find the maximum number of coins to make change. Example Say, I'm given coins of value 3 and 5, and I want to make change for 15, the solution would be {3,3,3,3,3}…
tubby
  • 2,074
  • 3
  • 33
  • 55
0
votes
1 answer

Unbounded knapsack/coin change with optimal solution for non-standard coins

I have the following problem: Given a target size N and some denominations of some randomly generated coins stored in array denominations[] check using dynamic programming if there is an optimal solution which will fill the entire target with…
Theocharis K.
  • 1,281
  • 1
  • 16
  • 43
0
votes
1 answer

Min-Coin Change variation

The Min-Coin Change problem is well-studied (an explanation can be found here: http://www.algorithmist.com/index.php/Min-Coin_Change), but I am interested in solving a variation on it: For a set of values V, determine a minimal set of coins C such…
Arthelais
  • 606
  • 1
  • 7
  • 17
0
votes
1 answer

change-making problems with some modifications

In change-making problem with following Greedy algorithms, addresses the following question: how can a given amount of money be made with the least number of coins? Algorithm: using most valuable coins, if it possible. Suppose we have infinite…
user4554402
0
votes
1 answer

Asymptotic Run Time Analysis -- Coin Change Algorithm

I need help finding the Asymptotic run time, i.e. Big O(n), of the following algorithm--> change_slow() . I've tried masters method and other techniques but can't seem to find the answer. This is a coin change problem, processed with the following…
0
votes
2 answers

Making Change with least amount of Coins using recursion

Hello i'm having trouble writing this function. The objective is to write a function that computes the least amount of coins needed to make change. The function has to use recursion and you are not able to use loops of any kind. The reason why i'm…
Bob506
  • 1
  • 1
0
votes
1 answer

Trace a recursive coin change algorithm

I am trying to trace this recursive algorithm of the coin change problem with M=10, c={5,3,1} and d=3. M is the value of money for which change is required, c is the different coin values available and d is the number of different coin values…
Saiyan
  • 197
  • 7
  • 22