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

Hiring now

Get the Oracle interview, not just the prep

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
Or practice this question first

Next question