Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 827 Bytes

_746. Min Cost Climbing Stairs.md

File metadata and controls

34 lines (24 loc) · 827 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : July 05, 2024

Last updated : July 05, 2024


Related Topics : Array, Dynamic Programming

Acceptance Rate : 66.27 %


Solutions

Python

class Solution:
    def minCostClimbingStairs(self, cost: List[int]) -> int:
        dp = [0] * 2 + [0] * len(cost)
        for i, cost in enumerate(cost, 2) :
            dp[i] = cost + min(dp[i - 1], dp[i - 2])
        return min(dp[-2:])