🧠 Before you code — what pattern fits?
cost[i] is the cost of the i-th step; after paying you can climb one or two steps. You can start from step 0 or step 1. Return the minimum cost to reach the top of the floor (past the last step).
[10,15,20] → 15
[1,100,1,1,1,100,1,1,100,1] → 6
🎬 Video explanation · NeetCode
Your solution runs against 2 unit tests, including edge and large-value cases.
Loading...
Test console · 2 unit tests
Submit your code to run it against all 2 unit tests. Results appear here.
JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.