mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 19:44:45 +08:00
Update 0746.使用最小花费爬楼梯.md
Added python version code
This commit is contained in:
@ -225,7 +225,16 @@ class Solution {
|
|||||||
```
|
```
|
||||||
|
|
||||||
Python:
|
Python:
|
||||||
|
```python
|
||||||
|
class Solution:
|
||||||
|
def minCostClimbingStairs(self, cost: List[int]) -> int:
|
||||||
|
dp = [0] * (len(cost))
|
||||||
|
dp[0] = cost[0]
|
||||||
|
dp[1] = cost[1]
|
||||||
|
for i in range(2, len(cost)):
|
||||||
|
dp[i] = min(dp[i - 1], dp[i - 2]) + cost[i]
|
||||||
|
return min(dp[len(cost) - 1], dp[len(cost) - 2])
|
||||||
|
```
|
||||||
|
|
||||||
Go:
|
Go:
|
||||||
```Go
|
```Go
|
||||||
|
Reference in New Issue
Block a user