mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-07 15:45:40 +08:00
Update 0377.组合总和Ⅳ.md
新增C语言实现
This commit is contained in:
@ -312,7 +312,28 @@ impl Solution {
|
||||
}
|
||||
}
|
||||
```
|
||||
### C
|
||||
|
||||
```c
|
||||
int combinationSum4(int* nums, int numsSize, int target) {
|
||||
int dp[target + 1];
|
||||
memset(dp, 0, sizeof (dp ));
|
||||
dp[0] = 1;
|
||||
for(int i = 0; i <= target; i++){
|
||||
for(int j = 0; j < numsSize; j++){
|
||||
if(i - nums[j] >= 0 && dp[i] < INT_MAX - dp[i - nums[j]]){
|
||||
dp[i] += dp[i - nums[j]];
|
||||
}
|
||||
}
|
||||
}
|
||||
return dp[target];
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
### C#
|
||||
|
||||
```csharp
|
||||
public class Solution
|
||||
{
|
||||
@ -340,4 +361,3 @@ public class Solution
|
||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||
</a>
|
||||
|
||||
|
Reference in New Issue
Block a user