easy understanding 68ms DP python solution


  • 0
    W
    class Solution(object):
        def combinationSum4(self, nums, target):
            """
            :type nums: List[int]
            :type target: int
            :rtype: int
            """
            l=len(nums)
            bank=[1]+[0]*target
            for i in range(1,target+1):
                for j in nums:
                    if i-j>=0:
                        bank[i]+=bank[i-j]
            return bank[target]
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.