添加0377.组合总和Ⅳ Python版本
This commit is contained in:
parent
8ce5dcff6f
commit
43c57b8c52
|
|
@ -148,9 +148,22 @@ C++测试用例有超过两个树相加超过int的数据,所以需要在if里
|
||||||
|
|
||||||
Java:
|
Java:
|
||||||
|
|
||||||
|
|
||||||
Python:
|
Python:
|
||||||
|
|
||||||
|
```python
|
||||||
|
class Solution:
|
||||||
|
def combinationSum4(self, nums, target):
|
||||||
|
dp = [0] * (target + 1)
|
||||||
|
dp[0] = 1
|
||||||
|
|
||||||
|
for i in range(1, target+1):
|
||||||
|
for j in nums:
|
||||||
|
if i >= j:
|
||||||
|
dp[i] += dp[i - j]
|
||||||
|
|
||||||
|
return dp[-1]
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue