4-liner in Python, 60ms

  • 1

    I've learned so much from you guys lately, especially code golfers like @StefanPochmann

    Trying to catch up here:

            dp = [1]
            for i in range(1, target+1):
                dp.append(sum(dp[i-n] for n in nums if i-n >= 0))
            return dp[target]

  • 0

    Ha, I was going to post that today. Oh well, I still have some stuff left...

Log in to reply

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