Class Solution
java.lang.Object
g0701_0800.s0746_min_cost_climbing_stairs.Solution
746 - Min Cost Climbing Stairs.<p>Easy</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> cost = [10,15,20]</p>
<p><strong>Output:</strong> 15</p>
<p><strong>Explanation:</strong> You will start at index 1. - Pay 15 and climb two steps to reach the top. The total cost is 15.</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> cost = [1,100,1,1,1,100,1,1,100,1]</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> You will start at index 0.</p>
<ul>
<li>Pay 1 and climb two steps to reach index 2.</li>
<li>Pay 1 and climb two steps to reach index 4.</li>
<li>Pay 1 and climb two steps to reach index 6.</li>
<li>Pay 1 and climb one step to reach index 7.</li>
<li>Pay 1 and climb two steps to reach index 9.</li>
<li>Pay 1 and climb one step to reach the top.
The total cost is 6.</li>
</ul>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 <= cost.length <= 1000</code></li>
<li><code>0 <= cost[i] <= 999</code></li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minCostClimbingStairs
public int minCostClimbingStairs(int[] cost)
-