Skip to main content
mediumNeetCode 150

Coin Change II

Given an array of coin denominations and a target amount Return the number of different combinations that make up the amount You have infinite coins of each denomination Example: amount = 5, coins = [1,2,5] => 4 The combinations are: [5], [2,2,1], [2,1,1,1], [1,1,1,1,1]

Coin on the outside loop, amount on the inside. That single ordering is what stops me counting the same combination twice.

Arrays & HashingDynamic Programming

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Typing with Coco is free when you sign in, up to a daily limit. Talking with her out loud comes with the $79 pack. Anyone can open the editor and run their code.

1Number of Ways to Make Amountmedium
Based onLeetCode