Dsa
Dynamic Programming
Easy
Min Cost Climbing Stairs
You are climbing a staircase and you can either take one step or two steps at a time. The cost of each step is given in an array, where the ith element represents the cost of step i. The total cost of reaching the top (beyond the last step) should be minimized. You can start from either the first or second step. Write a program to find the minimum cost to reach the top of the staircase. The first line of input contains an integer n (2 <= n <= 100), the number of steps. The second line contains n space-separated integers representing the costs. Output the minimum cost.
Example:
Input:
4
10 15 20 25
Output:
15
Key concepts
dynamic_programmingarraygreedy
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now