Given an array where cost[i] is the cost of stepping on stair i, you may start from step 0 or step 1 and climb one or two steps at a time. Return the minimum cost to reach the top (one step past the last stair).
cost = [10,15,20]15cost = [1,100,1,1,1,100,1,1,100,1]6Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Break a problem into overlapping subproblems along a single dimension — like "the answer up to index i" — solve each one once, and reuse the result instead of recomputing it.
Read the full 1-D Dynamic Programming guide →
Original problem on LeetCode ↗