← All mock interviewsHints used: 0
Coin Change Mock Interview
- ✓Problem→
- 2Clarifying Questions→
- 3Constraints→
- 4Brute Force→
- 5Complexity Analysis→
- 6Pattern Recognition→
- 7Optimized Solution→
- 8Implementation→
- 9Testing→
- 10Follow-Up→
- 11Evaluation
Problem
You are given an array coins of distinct positive coin denominations and an integer amount. Return the fewest number of coins needed to make up exactly amount. You have an unlimited supply of each coin. If the amount cannot be made, return -1.
Constraints
- 1 ≤ coins.length ≤ 12
- 1 ≤ coins[i] ≤ 2^31 - 1
- 0 ≤ amount ≤ 10^4
Example
in: coins = [1,2,5], amount = 11
out: 3
Clarify
Before choosing anything: what would you ask the interviewer? What assumptions are you making? (Duplicates? Empty input? Value ranges? What to return when there is no answer?)