Problem
You get an integer array cost. Each item is the price of one step on a staircase. The value cost[i] is the price of step i.
You start on step 0 or on step 1. Each time that you leave a step i, you pay cost[i] and climb 1 step or 2 steps.
The top of the staircase is the position after the last step. Return the minimum total price to reach the top.
Example 1
- Input:
- cost = [5,12,3]
- Output:
- 8
- Explanation:
- Start on step 0 and pay 5 to climb to step 2. Then pay 3 to climb to the top. The total is 8.
Example 2
- Input:
- cost = [2,50,2,2,50,2]
- Output:
- 8
- Explanation:
- Stand on steps 0, 2, 3 and 5. Each of these steps has the price 2, so the total is 8.
Example 3
- Input:
- cost = [7,4]
- Output:
- 4
- Explanation:
- Start on step 1, pay 4 and climb 1 step to the top.
Constraints
- 2 <= cost.length <= 1000
- 0 <= cost[i] <= 999
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Climbing Stairs
Coding · Dynamic Programming · Math · Memoization
- Min Cost to Connect All Points
Coding
- Calculate Total Shipping Cost for an Order
Coding
- Closest Dessert Cost
Coding
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 746. Min Cost Climbing Stairs
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source