Coin Change Problem

Asked atOracle
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Clarify whether every denomination may be reused and whether the goal is minimum coins or number of combinations
  2. 02Define dp[a] as the best answer for amount a, with dp[0] = 0 and unreachable amounts set to infinity
  3. 03For each amount, relax dp[a] from dp[a - coin] + 1 for every usable coin
  4. 04Explain iteration order and return the unreachable sentinel as the required failure value
  5. 05Check amount zero, no solution, duplicate denominations, and large amounts

Reference answer

Then expect these follow-ups

  • What constraint would change your chosen approach?

    Tests: constraint adaptation

  • How would you test the edge cases before implementation?

    Tests: implementation extension

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question