parent
fe0abe75fd
commit
79a42b8535
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue