Dynamic Programming•Pattern: Unbounded Knapsack / DP•Medium

Coin change — minimum coins to make amount

Problem Intuition & Objective

Find the fewest coins needed to make up a given amount.

Time ComplexityO(amount × coins)
Optimal
Space ComplexityO(amount)
Memory Bounds
Optimal Algorithmic Approach

Bottom-up DP with 1D array.

Core Invariants & Edge Cases

  • dp[i] = min coins to make amount i
  • dp[0] = 0; dp[i] = min(dp[i - coin] + 1) for each coin ≤ i
  • If dp[amount] == INT_MAX, return -1
Previous ProblemLongest increasing subsequence (LIS)Next Problem 0/1 Knapsack problem

System Design & Architecture Roadmap

Coding interviews are only 50% of the bar. Master High-Level Design, distributed systems, and Object-Oriented LLD.