LC 0746 [E] Min Cost Climbing Stairs - ALawliet/algorithms GitHub Wiki

class Solution:
    def minCostClimbingStairs(self, cost: List[int]) -> int:
        cost.append(0) # the end is actually 1 past the end of the array
        
        for i in range(len(cost) - 3, -1, -1):
            cost[i] += min(cost[i+1], cost[i+2])
            
        return min(cost[0], cost[1])