当前位置:网站首页>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 botu - basic operation
- The biggest winner is China Telecom. Why do people dislike China Mobile and China Unicom?
- [key points of final review of modern electronic assembly]
- The principle and common methods of multithreading and the difference between thread and runnable
- shell_2
- 捡起MATLAB的第(9)天
- Compile, connect -- Notes
- 一文掌握vscode远程gdb调试
- Solution to the fourth "intelligence Cup" National College Students' IT skills competition (group B of the final)
- Day (4) of picking up matlab
猜你喜欢
Gartner predicts that the scale of cloud migration will increase significantly; What are the advantages of cloud migration?
C语言自编字符串处理函数——字符串分割、字符串填充等
Unity shader learning
Interview question 17.10 Main elements
Read the meaning of serial port and various level signals
C, calculation method and source program of bell number
Using JSON server to create server requests locally
Day (8) of picking up matlab
Download and install mongodb
OAK-D树莓派点云项目【附详细代码】
随机推荐
捡起MATLAB的第(9)天
Hyperbdr cloud disaster recovery v3 Version 2.1 release supports more cloud platforms and adds monitoring and alarm functions
捡起MATLAB的第(8)天
homwbrew安装、常用命令以及安装路径
捡起MATLAB的第(7)天
Vision of building interstellar computing network
The principle and common methods of multithreading and the difference between thread and runnable
Es common query, sorting and aggregation statements
Application case of GPS Beidou high precision satellite time synchronization system
面试题 17.10. 主要元素
Leetcode-396 rotation function
Spark 算子之filter使用
Win11/10家庭版禁用Edge的inprivate浏览功能
Function summary of drawing object arrangement in R language
[section 5 if and for]
OAK-D树莓派点云项目【附详细代码】
捡起MATLAB的第(6)天
运维流程有多重要,听说一年能省下200万?
第九天 static 抽象类 接口
ESP32_ Arduino