LeetCode 322 Coin Change - Why Naive Fails

The trap

Try all combinations of coins that sum to the target.

With amount aa and smallest coin cc, you might use up to a/ca/c coins. The number of combinations grows exponentially.

Can you build the minimum for amount aa from solutions to smaller amounts?