mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 00:43:04 +08:00
Update 0518.零钱兑换2,添加C#
This commit is contained in:
@ -347,6 +347,26 @@ object Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
### C#
|
||||
```csharp
|
||||
public class Solution
|
||||
{
|
||||
public int Change(int amount, int[] coins)
|
||||
{
|
||||
int[] dp = new int[amount + 1];
|
||||
dp[0] = 1;
|
||||
for (int i = 0; i < coins.Length; i++)
|
||||
{
|
||||
for (int j = coins[i]; j <= amount; j++)
|
||||
{
|
||||
if (j >= coins[i])
|
||||
dp[j] += dp[j - coins[i]];
|
||||
}
|
||||
}
|
||||
return dp[amount];
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
|
Reference in New Issue
Block a user