solulubeta
Sign in
Recursion & Memo / DP patterns for coding tests
04.08 · Problem

Coin Change: Fewest Coins

Medium Unlimited supply: minimum LC 322 Pro

You have an unlimited number of coins of each value. Return the fewest coins that add up to exactly amount, or −1 if it can’t be done.

Examples

Example 1

Input:  coins = [1, 2, 5], amount = 11
Output: 3

5 + 5 + 1.

solulu Pro

Continue this problem with Pro

Inside: step-by-step hints · 12 hidden tests · reference solutions · code editor.

Lifetime ₹1,999 ₹999 · Launch offer
Mark this problem as solved when you are finished.

Item 34 of 44 · updated 2026-10-13