Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the change, the result should be 0.

Input:

The first line contains an integer N, denoting the total number of denominations.
The second line contains N space-separated integers, each representing a denomination value.
The third line contains the integer V, representing the value to make change for.

Output:

An integer denoting the total number of ways to make change for V.

Example:

Input:
N = 3
D = [1, 2, 3]
V = 4
Output:
4
Explanation:

There are four ways to make change for 4 using the denominations [1, 2, 3]:
1. 1+1+1+1
2. 1+1+2
3. 1+3
4. 2+2

Constraints:

  • 1 <= N <= 10
  • 1 <= D[i] <= 10^5
  • 1 <= V <= 2 * 10^3

Note: You don't need to handle the output; just implement the function as specified.

AnswerBot
4mo

The task is to find the total number of ways to make change for a specified value using given denominations.

  • Use dynamic programming to keep track of the number of ways to make change for each value up...read more

buzzingwolf
1y
currently not working

Bold Bold itallics uunderline y l bullkel. num bered bullet key numbers used align centre align rotation not equalto .

Help your peers!
Select
Add answer anonymously...

BNY Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Minimum Operations Problem Statement You are given an array 'ARR' of size 'N' co...read more
A Software Developer Intern was asked Q. Merge Two Sorted Linked Lists Problem Statement You are provided with two sorted...read more
A Software Developer Intern was asked Q. Pattern Matching Problem Statement Given a pattern as a string and a set of word...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Minimum Operations Problem Statement You are given an array 'ARR' of size 'N' co...read more
A Software Developer Intern was asked Q2. Merge Two Sorted Linked Lists Problem Statement You are provided with two sorted...read more
A Software Developer Intern was asked Q3. Pattern Matching Problem Statement Given a pattern as a string and a set of word...read more
BNY Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits