当前位置:网站首页>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
边栏推荐
- How important is the operation and maintenance process? I heard it can save 2 million a year?
- Grbl learning (I)
- 451. 根据字符出现频率排序
- [open source tool sharing] MCU debugging assistant (oscillograph / modification / log) - linkscope
- C language --- string + memory function
- volatile的含义以及用法
- Win11 / 10 home edition disables the edge's private browsing function
- Interview question 17.10 Main elements
- Meaning and usage of volatile
- How to upgrade openstack across versions
猜你喜欢
Day (5) of picking up matlab
Hyperbdr cloud disaster recovery v3 Release of version 3.0 | upgrade of disaster recovery function and optimization of resource group management function
TIA botu - basic operation
力扣-198.打家劫舍
ESP32编译环境的搭建
捡起MATLAB的第(4)天
Install redis and deploy redis high availability cluster
Ice -- source code analysis
第十天 异常机制
451. 根据字符出现频率排序
随机推荐
Homewbrew installation, common commands and installation path
PS add texture to picture
The principle and common methods of multithreading and the difference between thread and runnable
C语言自编字符串处理函数——字符串分割、字符串填充等
Website pressure measurement tools Apache AB, webbench, Apache jemeter
力扣-746.使用最小花费爬楼梯
Import address table analysis (calculated according to the library file name: number of imported functions, function serial number and function name)
gps北斗高精度卫星时间同步系统应用案例
matplotlib教程05---操作图像
Cloud migration practice in the financial industry Ping An financial cloud integrates hypermotion cloud migration solution to provide migration services for customers in the financial industry
Config learning notes component
GRBL学习(二)
JVM - Chapter 2 - class loader subsystem
GRBL学习(一)
Fastjon2他来了,性能显著提升,还能再战十年
Es common query, sorting and aggregation statements
捡起MATLAB的第(8)天
Pgpool II 4.3 Chinese Manual - introductory tutorial
运维流程有多重要,听说一年能省下200万?
Implement default page