> For the complete documentation index, see [llms.txt](https://programming.arora-aditya.com/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://programming.arora-aditya.com/leetcode/dynamic-programming/518.-coin-change-2.md).

# 518. Coin Change 2

## Approach 1: Dynamic Programming

```python
class Solution(object):
    def change(self, amount, coins):
        """
        :type amount: int
        :type coins: List[int]
        :rtype: int
        """
        coins.sort()
        dp = [1] + [0] * (amount)
        for coin in coins:
            for i in range(-coin + amount + 1):
                dp[i+coin] += dp[i]
        return dp[amount]
```
