The Coin Vault
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Given a target amount and a list of coin denominations, return the minimum coins needed using a greedy strategy: repeatedly take the largest coin that does not exceed the remaining amount. Return -1 if the greedy approach cannot make exact change.
Summary
Exact change only - and you want to use as few coins as possible.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.