Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 414657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:18:15+00:00 2026-05-12T18:18:15+00:00

I want to know the idea of algorithm for the coin change problem where

  • 0

I want to know the idea of algorithm for the coin change problem where each denomination has infinte number of coins. Means how to apply DP (like the standard coin change problem)
For e.g in set 1,10,15,
change for 35 gives–2 coins of 10 and one coin of 15

Also give me an idea of brute forcing algorithm for this. I know to iterate over all the sets. But how to vary the number of each coin while brute forcing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:18:15+00:00Added an answer on May 12, 2026 at 6:18 pm

    I would think about building the solution one step at a time, inductively:

    Coins available are 1c, 5c, 10c, 25c (you can tweak them according to your needs)

    1. Minimun coins for 1c = 1 X 1c. Upto 4 cents, we need 1c coins, as that is the least denomination.
    2. For 5 cents, we have one 5c coin. Combining that with 4c above, we can generate any number between 1 and 9.
    3. For 10 cents, we need 1 X 10c. Combining the above three, we can generate any number between 1 and 19.
    4. For 20c, we need 2 x 10c, as 20 is divisible by 10.

    If you can formulate the problem inductively, it might be easier to tackle it.

    EDIT:
    Alright, here’s another attempt to explain the dynamic programming solution:

    Think of a table with x rows (x is number of distinct denominations) and n columns (n is the amount you have to build using least denominations). Every cell in this table represents a distinct sub-problem and will eventually contain the solution to it. Assume:

    row 1 represents the set {1c} i.e. in row 1 you are allowed to use infinite 1c
    row 2 represents the set {1c, 10c} i.e in row 2 you are allowed to infinite 1c and 10c
    row 3 represents the set {1c, 10c, 15c} and so on…
    Each column represents the amount you want to construct.

    Thus, every cell corresponds to one small sub-problem. For example (the indexes are starting from 1 for the sake of simplicity),
    cell(1, 5) ==> construct 5c using only {1c}
    cell(2, 9) ==> construct 9c using {1c, 10c}
    cell(3, 27) ==> construct 27c using {1c, 10c, 15c}
    Now your aim is to get the answer to cell(x, n)

    Solution:
    Start solving the table from the simplest problem. Solving the first row is trivial, since in the first row the only denomination available is {1c}. Every cell in row 1 has a trivial solution, leading to cell(1, n) = {nx1c} (n coins of 1c).

    Now proceed to the next row. Generalizing for the 2nd row, lets see how to solve for (say) cell(2, 28) i.e. construct 28c using {1c, 10c}. Here, you need to make a decision, whether to include 10c in the solution or not, and how many coins. You have 3 choices (3 = 28/10 + 1)

    Choice 1:
    Take {1x10c} and the rest from the previous row (which is stored in cell(1, 18)). This gives you {1x10c, 18x1c} = 19 coins

    Choice 2:
    Take {2x10c} and the rest from previous row (which is stored in cell(1, 8)). This gives you {2x10c, 8x1c} = 10 coins

    Choice 3:
    Take no 10c and the rest from the previous row (which is stored in cell(1, 28)). This gives you {28x1c} = 28 coins

    Clearly, choice 2 is the best as it takes less coins. Write it down in the table and proceed ahead. The table is to be filled one row at a time, and within a row, in the order of increasing amounts.

    Going by above rules, you will reach cell(x, n), the solution to which will be a choice between n/p + 1 alternatives, where p = newest denomination in row x. The best choice is your answer.

    The table actually memoizes the solutions to smaller problems, so that you don’t need to solve them again and again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know what a virtual base class is and what it means.
I want to know how to change the style of certain words and expressions
Want to know what the stackoverflow community feels about the various free and non-free
I want to know what are the options to do some scripting jobs in
I want to know what exactly is the sequence of calls that occurs when
I want to know which tool can be used to measure the cyclomatic complexity
I want to know how to use variables for objects and function names in
I want to know if i can create a custom google maps application,on which
I want to know how does the SQL Server know what @p# is in
i want to know how to edit a single row (which i select) from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.