746. 使用最小花费爬楼梯

 

 

 

 

 

 

 

 

1     def minCostClimbingStairs2(self, cost):
2         """
3         :type cost: List[int]
4         :rtype: int
5         """
6         cost1 = cost2 = 0
7         for i in cost:
8             cost1, cost2 = i + min(cost1, cost2), cost1
9         return min(cost1, cost2)

 

posted @ 2020-04-29 09:39  人间烟火地三鲜  阅读(158)  评论(0编辑  收藏  举报