Combination Sum IV LeetCode solution in Python

1
class Solution:
2
def combinationSum4(self, nums: List[int], target: int) -> int:
3
dp = [0] * (target + 1)
4
dp[0] = 1
5
for i in range(1, target + 1):
6
for num in nums:
7
num_before = i - num
8
if num_before >= 0:
9
dp[i] += dp[num_before]
10
return dp[target]

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0