Skip to main content

Questions tagged [coin-change]

Filter by
Sorted by
Tagged with
1 vote
1 answer
70 views

Minimum coins to make change when real numbers are allowed

There is the classical version of the minimum coins to make change problem where the change and the set of coins available are all integers. Given an infinite amount of each type of coin, we're asked ...
Rohit Pandey's user avatar
1 vote
1 answer
94 views

Coin exchange, find different triples of values

Suppose i have 3 coins: A, B, C. Each one of them have different value: a, b, c. And if want to exchange coins A for coins B, i need to be able to give exactly a units of currency A and get exactly b ...
dezzerlol's user avatar
0 votes
1 answer
919 views

What is the best way to solve the coin change problem using dynamic programming?

I have found two ways of applying dynamic programming to the coin change problem of finding the minimum number of coins from a given set of denominations to make a given sum. I wanted to know if one ...
JeanMi's user avatar
  • 111
6 votes
2 answers
2k views

Why does the order of the nested loops matter when solving the Coin Change problem?

The Coin Change problem is stated as: Given an integer array coins[ ] of size N representing different denominations of currency and an integer sum, find the number of ways you can make sum by using ...
Elad Maimoni's user avatar
1 vote
1 answer
79 views

Unable to understand how the while loop extracts the least number of coins with given sum

I was reading this classical Coin Problem (7.1): Given a set of coin values coins = {c1, c2,..., ck} and a target sum of money n, our task is to form the sum n using as few coins as possible. I fully ...
harshmangalamv's user avatar
1 vote
1 answer
122 views

Can the algorithm be optimized?

I am new to backtracking and recursion. I have seen numerous explanations on how on to find the minimum number of coins needed to make a particular amount. This involves a top down dynamic approach ...
Spindoctor's user avatar
2 votes
1 answer
3k views

Min-coin change problem with limited coins

I have been assigned the min-coin change problem for homework. I have to calculate the least number of coins needed to make change for a certain amount of cents in 2 scenarios: we have an infinite ...
Rikus Honey's user avatar
2 votes
3 answers
530 views

Algorithm for fewest number of moves with artificial minimum

I asked a question recently, but I need to be able to add an artificial minimum number of steps that can be larger than the Dijkstra minimum. To summarize, I built an undirected graph with edges ...
David Fox's user avatar
  • 103
1 vote
1 answer
1k views

dynamic pseudo-code for simplified coin changing algorithm

As a homework exercise our professor presented to us a simplified version of the coin-changing problem in which we do not need to minimize the number of coins used or track the number of possible ...
Trixie the Cat's user avatar
1 vote
1 answer
2k views

What Are the Ideas Behind Variations of the Coin Change Problem?

Problem: given a set of n coins of unique face values, and a value change, find number of ways of making change for ...
Abhijit Sarkar's user avatar
3 votes
2 answers
3k views

DP recurrence relations: Coin change vs Knapsack

Take: KP recurrence relation $ max { [v + f(k-1,g-w ), f(k-1,g)] } $ if w <= g and k>0 CCP recurrence relation $ min {[1 + f(r,c-v), f(r-1,c)]} $ if v <= c and r>0 I don't ...
degausser's user avatar
1 vote
1 answer
350 views

"Ways to make change for a dollar": How to optimize with constraints

I'm working on an algorithm that takes a number of unit coins ([1, 2, 5, 10] for example) and a certain amount of money (13 in this case), and figures out how many ways there are to provide change for ...
Trashtalk's user avatar
  • 113
2 votes
1 answer
2k views

Solving "coin exchange" for coins of power values by greedy algorithm

When solving the problem of coin exchange by greedy algorithm, why will we will always have the correct result if the coin values are $1, a, a^2, \cdots, a^n$, where $a\ge 2$ and $n\gt 0$? For ...
BoberMod's user avatar
  • 123
0 votes
1 answer
519 views

Coin Change Problem Recurrence Relation with one parameter

I have been looking through the recursive formulation for the coin change problem here and am wondering if it is possible to define the function $ C(N, m) $ in one parameter as $C(N)$, therefore not ...
user1933699's user avatar
1 vote
0 answers
100 views

Reducing Coin Change Problem running time to depend on the denominations, not sum being changed

I asked my Advanced Algorithms professor recently if we could solve the coin change problem (least number of coins necessary to make change for S cents using denominations d1, d2, ... dk). I thought ...
Riggster's user avatar
0 votes
0 answers
371 views

Space complexity of Coin change with memoization

I've read conflicting answers for the space complexity of the top down implementation w/ memoization for the classic coin change problem. Would this be O(N * M) space as Interview Cake says https://...
Gwater17's user avatar
  • 101
3 votes
3 answers
6k views

Find the lexicographically smallest order of N numbers such that the total of N numbers <= Threshold value

GIven a number N, Threshold T and an array A. Find the lexicographically smallest order of N numbers from A such that the total of these N numbers is <= T. This question is a simplification of ...
user248884's user avatar
1 vote
0 answers
36 views

Is this solution is bad for the coin change problem? [closed]

was doing coin change problem as an assignment(didnt know before), after came with this solution i checked the solutions available couldnt find a similar one like this, just curious. removing the ...
Ntwobike's user avatar
  • 111
1 vote
0 answers
134 views

Does an algorithm exist for solving the change-making problem using a finite coin library of known size?

I'm currently working on implementing an algorithm to solve a real-world problem I'm encountering in a lab, but with little background in algorithms, I'm struggling to create an ideal solution. I ...
michaelmccarthy404's user avatar
1 vote
2 answers
2k views

Printing actual solutions for the coin exchange problem

As I teach myself dynamic programming, I have learned about the coin exchange problems. Specially this site: https://www.geeksforgeeks.org/dynamic-programming-set-7-coin-change/ provides great insight ...
Octavio Castillo's user avatar
2 votes
1 answer
1k views

Dynamic Programming for a variant of the coin exchange problem

I am interested in solving a variant of the coin exchange problem. Recall the formal definition of the coin exchange problem: Given a value N, if we want to make change for N cents, and we have ...
Octavio Castillo's user avatar
0 votes
0 answers
286 views

Implementing supplies in Coin change problem

I started an algorithm course in C two months ago, for the last weeks I've been trying to solve this problem , i ran out of time but I cannot find an acceptable solution. Basically It's a coin change ...
mark's user avatar
  • 1
9 votes
1 answer
6k views

Analyzing time complexity for change making algorithm (Brute force)

I'm new to analyzing time complexities and I have a question. To compute the nth fibonacci number, the recurrence tree will look like so: Since the tree can have a maximum height of 'n' and at every ...
Bugaboo's user avatar
  • 193
5 votes
2 answers
1k views

Can counting problems have optimal substructure?

I understand that for a problem to be solvable using dynamic programming, it needs to have the following properties: optimal substructure overlapping subproblems I stumbled upon an article which ...
Izaan's user avatar
  • 220
3 votes
1 answer
7k views

Recurrence relation of the coin change problem

I'm trying to wrap my head around the coin change problem, where you try to find the total number of ways $N$ cents can be exchanged using $M$ coins $\{C_1, C_2, ..., C_m\}$. The recurrence relation ...
MarksCode's user avatar
  • 214
2 votes
2 answers
3k views

What are applications of Coin Change problem?

I've read so many about the Coin Change problem, debates about wheather it is solvable using Greedy, Dynamic Programming and so on. Nevertheless I cannot find an application of this problem. What ...
dariodip's user avatar
  • 874
2 votes
3 answers
924 views

Coin Change Problem(Greedy Algorithm)

In Coin Change Problem, if the ratio of Coin Value ($\frac{Coin_(i+1)}{coin(i)}$) is always increasing then we can use Greedy Algorithm? Example- $(1,3,4)$ are denominations of coin. If I want to pay ...
Dhrub Kumar's user avatar
3 votes
1 answer
3k views

A variant of coin change problem

Consider a cashier machine that takes payments in coins. We feed the machine coins one by one until the value is more than the amount we should have paid. Then the machine returns the extra amount in ...
Saeid's user avatar
  • 339