题目描述 出bug的时候输出打印dp就行

class Solution:
    def minCostClimbingStairs(self, cost: List[int]) -> int:
        n = len(cost)+1
        if n <=3:
            return min(cost[0],cost[1])
        dp = [0]*n
        cost.append(0)

        for i in range(2,n):
            if dp[i-1]+cost[i-1]>dp[i-2]+cost[i-2]:
                dp[i] = dp[i-2]+cost[i-2]
            else:
                dp[i] = dp[i-1]+cost[i-1]
        return dp[-1]

运行结果:

746. Min Cost Climbing Stairs刷题笔记_python