Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Created August 11, 2018 09:17
Show Gist options
  • Save luojiyin1987/5a46393717a29182f3f14cc1fd33e830 to your computer and use it in GitHub Desktop.
Save luojiyin1987/5a46393717a29182f3f14cc1fd33e830 to your computer and use it in GitHub Desktop.
Min Cost Climbing Stairs
class Solution:
def minCostClimbingStairs(self, cost):
"""
:type cost: List[int]
:rtype: int
"""
size = len(cost)
dp = [cost[0], cost[1]]
for x in range(2, size):
dp.append(min(dp[x -1], dp[x-2]) + cost[x])
return min(dp[-1], dp[-2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment