Coin Change Mock Interview

  1. Problem
  2. 2Clarifying Questions
  3. 3Constraints
  4. 4Brute Force
  5. 5Complexity Analysis
  6. 6Pattern Recognition
  7. 7Optimized Solution
  8. 8Implementation
  9. 9Testing
  10. 10Follow-Up
  11. 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?)