Summary
Keywords
Full Transcript
LeetCode 746 β Min Cost Climbing Stairs (Easy) Youβre given an array cost[] where cost[i] is the cost to step on stair i. After paying, you can climb 1 or 2 steps. You can start at index 0 or index 1. This video shows the clean Dynamic Programming solution and the standard optimization from O(n) space to O(1) space. Approach (DP idea) Let dp[i] be the minimum cost to reach step i. Transition: dp[i] = cost[i] + min(dp[i-1], dp[i-2]) Answer: min(dp[n-1], dp[n-2]) Complexity Time: O(n) Space: O(1) (optimized) If you want the next problem covered, comment: βNEXTβ and paste the number. Website: https://lanacademy-school.thinkific.com Twitter/X: https://x.com/SolutionsLan #leetcode #dynamicprogramming #codinginterview #algorithms #interviewprep #coding #leetcode #leetcodecoding #leetcodesolution #leetcodechallenge #faang #fang #computerscience #cs #codingtiktok #coding #codinglife #boostofhope #fyp #codinginterview #softwareengineer #swe #tech #foryou #python #learntocode #google #techtok #programming #algorithms #learntocode @reper #foryou #viral #reper #urmaritori #for
