Python DP


  • 0
    class Solution(object):
        def combinationSum4(self, nums, target):
            f = [1] + [0] * target
            for i in range(1,len(f)):
                for x in nums:
                    if x <= i:
                         f[i] += f[i-x]
            return f[-1]

Log in to reply
 

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