4 lines accepted python


  • 0
    class Solution(object):
        def minCostClimbingStairs(self, cost):
            """
            :type cost: List[int]
            :rtype: int
            """
            getThere = [0, 0]
            for i in range(2, len(cost)):
                getThere.append(min(getThere[i - 2] + cost[i - 2], getThere[i - 1] + cost[i - 1]))
            return min(getThere[-2] + cost[-2], getThere[-1] + cost[-1])

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.