题目要求:
https://leetcode-cn.com/problems/min-cost-climbing-stairs/
class Solution:
def minCostClimbingStairs(self, cost: List[int]) -> int:
if len(cost) == 0:
return 0
if len(cost) == 1:
return cost[0]
if len(cost) == 2:
return min(cost[0],cost[1])
dp = [0] * len(cost)
dp[0] = cost[0]
dp[1] = cost[1]
for i in range(2,len(cost)):
dp[i] = min(dp[i-2]+cost[i], dp[i-1]+cost[i])
return min(dp[i],dp[i-1])