当前位置:网站首页>Force buckle-746 Climb stairs with minimum cost
Force buckle-746 Climb stairs with minimum cost
2022-04-23 16:06:00 【Node_ Su】
I don't quite understand the topic , Standing on the 0 and 1 There is no need to spend ?
dp[i] Indicates reaching the current stair i The minimum cost of time
class Solution(object):
def minCostClimbingStairs(self, cost):
"""
:type cost: List[int]
:rtype: int
"""
n = len(cost)
dp = [0] * (n + 1)
for i in range(2, n + 1):
dp[i] = min(cost[i - 1] + dp[i - 1], cost[i - 2] + dp[i - 2])
return dp[n]
if __name__ == '__main__':
cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1]
Sol = Solution()
res = Solution.minCostClimbingStairs(Sol, cost)
print(res)
版权声明
本文为[Node_ Su]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231603458159.html
边栏推荐
- TIA博图——基本操作
- linux上啟動oracle服務
- The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
- Cloudy data flow? Disaster recovery on cloud? Last value content sharing years ago
- GRBL学习(一)
- Day (3) of picking up matlab
- Day (6) of picking up matlab
- Government cloud migration practice: Beiming digital division used hypermotion cloud migration products to implement the cloud migration project for a government unit, and completed the migration of n
- Function summary of drawing object arrangement in R language
- What is the experience of using prophet, an open source research tool?
猜你喜欢
捡起MATLAB的第(5)天
保姆级Anaconda安装教程
Cloudy data flow? Disaster recovery on cloud? Last value content sharing years ago
C#,贝尔数(Bell Number)的计算方法与源程序
Coalesce and repartition of spark operators
Oak-d raspberry pie cloud project [with detailed code]
Intersection, union and difference sets of spark operators
撿起MATLAB的第(9)天
力扣-198.打家劫舍
贫困的无网地区怎么有钱建设网络?
随机推荐
dlopen/dlsym/dlclose的简单用法
实现缺省页面
【现代电子装联期末复习要点】
Compile, connect -- Notes
一文掌握vscode远程gdb调试
Open source project recommendation: 3D point cloud processing software paraview, based on QT and VTK
451. 根据字符出现频率排序
5 minutes, turn your excel into an online database, the magic cube net table Excel database
Intersection, union and difference sets of spark operators
Master vscode remote GDB debugging
Sort by character occurrence frequency 451
[AI weekly] NVIDIA designs chips with AI; The imperfect transformer needs to overcome the theoretical defect of self attention
下载并安装MongoDB
Application case of GPS Beidou high precision satellite time synchronization system
Simple usage of dlopen / dlsym / dlclose
捡起MATLAB的第(2)天
How to upgrade openstack across versions
捡起MATLAB的第(9)天
Fastjon2他来了,性能显著提升,还能再战十年
Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years