当前位置:网站首页>leetcode 120. 三角形最小路径和
leetcode 120. 三角形最小路径和
2022-06-11 15:17:00 【失忆机器】

动态规划问题。dp数组,方程为dp[j][i] = Math.min(dp[j+1][i],dp[j+1][i+1]) + 当前value值。
java代码如下
class Solution {
public int minimumTotal(List<List<Integer>> triangle) {
int n = triangle.size();
int[][] dp = new int[n+1][n+1];
for(int j = n - 1; j >= 0; j--){
for(int i = 0; i <= j; i++){
dp[j][i] = Math.min(dp[j+1][i],dp[j+1][i+1]) + triangle.get(j).get(i);
}
}
return dp[0][0];
}
}边栏推荐
- Turning "passive" into "active", how to build security compliant intelligent products | Q recommendation
- B站高管解读财报:疫情对公司长期发展无影响 视频化趋势不可阻挡
- Hashicopy之nomad应用编排方案05(访问web页面)
- Mysql database optimization details
- 容易让单片机程序跑飞的原因
- Recyclerview usage record
- In depth analysis of "circle group" relationship system design | series of articles on "circle group" technology
- 02 Tekton Pipeline
- 01Tekton 初探
- Iclr2022| small sample fine tuning method of language model based on differentiable hints
猜你喜欢

见微知著,细节上雕花:SVG生成矢量格式网站图标(Favicon)探究

Tencent interviewers share their interview experience, how to evaluate the interviewers' technical and personal comprehensive quality, and give you some suggestions on the interview

Social software soul withdraws its IPO application: Tencent is a major shareholder

What is excess product power? Find the secret key of the second generation cs75plus in the year of the tiger

Cisco Rui submitted the registration of sci tech Innovation Board: proposed to raise 600million yuan, with annual revenue of 222million yuan

深度剖析「圈組」關系系統設計 | 「圈組」技術系列文章

Hebei huangjinzhai scenic spot adds "AED automatic defibrillator" to ensure the life safety of tourists!

uniapp开发微信小程序,从构建到上线

社交软件Soul撤回IPO申请:上市只差临门一脚 腾讯是大股东

你还不懂线程池的设计及原理吗?掰开揉碎了教你设计线程池
随机推荐
数据库“百亿蓝海”中,每位玩家都能找到一叶扁舟 | C位面对面
In depth analysis of "circle group" relationship system design | series of articles on "circle group" technology
Safepoint explanation and analysis of its placement ideas
Nexus configuration Yum repository for repository manager
如何做好自媒体?这几个步骤你做对了吗?
Ali, tell me about the application scenarios of message oriented middleware?
Taking log4j as an example, how to evaluate and classify security risks
How about art plus online school? Is it a new online organization?
新华三交换机系统基本配置命令
Hamad application layout scheme 03 of hashicopy (run a job)
Nexus of repository manager
对于事务的认识
当开源遇见 KPI,全球化 VS 本土化,开源的理想与现实该如何和解?
Recyclerview usage record
Lick the dog till the last one has nothing (linear DP)
[mysql_12] MySQL data types
架构概念探索:以开发纸牌游戏为例
思科瑞递交科创板注册:拟募资6亿 年营收2.22亿
01discussion on Tekton
Qcustomplot 1.0.1 learning (1) - Download and use qcustomplot