<p>You are given an integer array <code>cost</code> where <code>cost[i]</code> is the cost of <code>i<sup>th</sup></code> step on a staircase. Once you pay the cost, you can either climb one or two steps.</p>

<p>You can either start from the step with index <code>0</code>, or the step with index <code>1</code>.</p>

<p>Return <em>the minimum cost to reach the top of the floor</em>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> cost = [10,<u>15</u>,20]
<strong>Output:</strong> 15
<strong>Explanation:</strong> You will start at index 1.
- Pay 15 and climb two steps to reach the top.
The total cost is 15.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> cost = [<u>1</u>,100,<u>1</u>,1,<u>1</u>,100,<u>1</u>,<u>1</u>,100,<u>1</u>]
<strong>Output:</strong> 6
<strong>Explanation:</strong> You will start at index 0.
- Pay 1 and climb two steps to reach index 2.
- Pay 1 and climb two steps to reach index 4.
- Pay 1 and climb two steps to reach index 6.
- Pay 1 and climb one step to reach index 7.
- Pay 1 and climb two steps to reach index 9.
- Pay 1 and climb one step to reach the top.
The total cost is 6.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= cost.length &lt;= 1000</code></li>
	<li><code>0 &lt;= cost[i] &lt;= 999</code></li>
</ul>

class Solution:
    # def dfs(self, idx, cost, dp):
    #     if idx < 0:
    #         return 0
    #     if idx in dp:
    #         return dp[idx]
    #     left = self.dfs(idx-1, cost, dp) + cost[idx-1]
    #     if idx-2 < 0:
    #         right = float("inf")
    #     else:
    #         right = self.dfs(idx-2, cost, dp) + cost[idx-2]
    #     dp[idx] = min(left, right)
    #     return dp[idx]
    
    def compute(self, cost):
        dp = [0 for _ in range(len(cost)+1)]
        
        for i in range(1, len(cost)+1):
            left = dp[i-1] + cost[i-1]
            right = float("inf") if i-2 < 0 else dp[i-2]+cost[i-2]
            dp[i] = min(left, right)
        
        return dp[len(cost)]
        
    
    def minCostClimbingStairs(self, cost: List[int]) -> int:
#         dp = {}
#         dp[0] = 0
#         stZ = self.dfs(len(cost), cost, dp)
        
#         dp = {}
#         dp[0] = 0
#         stO = self.dfs(len(cost)-1, cost[1:], dp)
#         return min(stZ, stO)
        
        
        stZ = self.compute(cost)
        stO = self.compute(cost[1:])
        
        return min(stZ, stO)
16800