parent
a55dca64ed
commit
6bae30472c
|
|
@ -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#
|
### C#
|
||||||
|
|
||||||
```csharp
|
```csharp
|
||||||
public class Solution
|
public class Solution
|
||||||
{
|
{
|
||||||
|
|
@ -340,4 +361,3 @@ public class Solution
|
||||||
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
<a href="https://programmercarl.com/other/kstar.html" target="_blank">
|
||||||
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
<img src="../pics/网站星球宣传海报.jpg" width="1000"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue