Dsa
Greedy
Medium
Minimum Coin Change
You are given an amount of money and a list of different denominations of coins. Your task is to determine the minimum number of coins needed to make the given amount. Assume you have an unlimited supply of each coin denomination.
Input format:
- The first line contains an integer A (1 ≤ A ≤ 1,000,000), the amount of money.
- The second line contains an integer N (1 ≤ N ≤ 100), the number of different coin denominations.
- The third line contains N integers which are the denominations of the coins, guaranteed to be distinct and sorted in descending order.
Output format:
- Print a single integer: the minimum number of coins needed to make the amount.
Example:
Input:
11
3
5 2 1
Output:
3
Key concepts
greedyminimizationcurrency
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now