mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Update 0377.组合综合4,添加C#
This commit is contained in:
@ -312,6 +312,28 @@ impl Solution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
### C#
|
||||||
|
```csharp
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public int CombinationSum4(int[] nums, int target)
|
||||||
|
{
|
||||||
|
int[] dp = new int[target + 1];
|
||||||
|
dp[0] = 1;
|
||||||
|
for (int i = 0; i <= target; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < nums.Length; j++)
|
||||||
|
{
|
||||||
|
if (i >= nums[j] && dp[i] < int.MaxValue - dp[i - nums[j]])
|
||||||
|
{
|
||||||
|
dp[i] += dp[i - nums[j]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dp[target];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
Reference in New Issue
Block a user