Created
August 11, 2018 09:17
-
-
Save luojiyin1987/5a46393717a29182f3f14cc1fd33e830 to your computer and use it in GitHub Desktop.
Min Cost Climbing Stairs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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