#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
    Copyright 2020, <NAME>, UIUC.
    Using Dynamic Programming to solve min cost climbing stairs problem.
 '''

class Solution(object):
    def minCostClimbingStairs(self, cost):
        """
        :type cost: List[int]
        :rtype: int
        """
        n = len(cost)

        if n == 2:
            return min(cost)

        dp = [0] * (n+1)

        for i in range(2, n+1):
            dp[i] = min(dp[i-1]+cost[i-1], dp[i-2]+cost[i-2])

        return dp[-1]

#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
    Copyright 2020, <NAME>, UIUC.
    Using Dynamic Programming to solve min cost climbing stairs problem.
 '''

class Solution(object):
    def minCostClimbingStairs(self, cost):
        """
        :type cost: List[int]
        :rtype: int
        """
        n = len(cost)

        if n == 2:
            return min(cost)

        dp = [0] * (n+1)

        for i in range(2, n+1):
            dp[i] = min(dp[i-1]+cost[i-1], dp[i-2]+cost[i-2])

        return dp[-1]

#!/usr/bin/env python # -*- coding: utf-8 -*- Copyright 2020, <NAME>, UIUC.     Using Dynamic Programming to solve min cost climbing stairs problem. :type cost: List[int]         :rtype: int