Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

cost =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

DP where dp[i] is min cost to reach the top starting from step i.

Approach

Compute from the end: dp[i] = cost[i] + min(dp[i+1], dp[i+2]). Answer is min(dp[0], dp[1]).

Code
Loading...
Complexity
Time: O(n)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

DP where dp[i] is min cost to reach the top starting from step i.

Approach

Compute from the end: dp[i] = cost[i] + min(dp[i+1], dp[i+2]). Answer is min(dp[0], dp[1]).

Code
Loading...
Complexity
Time: O(n)
Space: O(1)