Dsa
Dynamic Programming
Warm-up
Weighted Coin Change
You are given a list of coins, each with a certain value and weight. You need to determine the maximum value you can obtain with a fixed weight limit when combining these coins. The same coin can be used multiple times. Output the maximum value possible.
Input format:
- The first line contains two integers, n (the number of coins) and W (the maximum weight).
- The next n lines each contain two integers, value and weight (the value and weight of each coin).
Output format:
- A single integer representing the maximum value obtainable.
Example:
Input:
3 50
60 10
100 20
120 30
Output:
300
Key concepts
dynamic_programmingcombinatoricsgreedy
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