当前位置:网站首页>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];
}
}边栏推荐
- The server prevents repeated payment of orders
- In the "ten billion blue ocean" database, each player can find a boat | c-position face-to-face
- Implementation of gray-scale publishing scheme for microservice architecture based on gateway and Nacos
- With a loss of 13.6 billion yuan in three years, can listing revive Weima?
- Elk log analysis system
- Nexus configuration Yum repository for repository manager
- Analyse approfondie de la conception du système relationnel du Groupe de cercles
- Did you break the rules?
- Summary of some classic embedded C interview questions
- Hamad application layout scheme 03 of hashicopy (run a job)
猜你喜欢

Elk log analysis system

Avenue to Jane | Comment concevoir un vit pour configurer l'auto - attraction est - il le plus raisonnable?

19. Insertion et suppression d'un arbre de recherche binaire

3年亏损136亿,上市能救活威马吗?

Illustration of tiger international quarterly report: revenue of USD 52.63 million continued to be internationalized
[mysql_12] MySQL data types

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

Lick the dog till the last one has nothing (linear DP)

19. 二叉搜索树的插入删除修剪

In depth analysis of "circle group" relationship system design | series of articles on "circle group" technology
随机推荐
Installation and use of sonarqube
Learn more about and use ThreadLocal
Understanding of oauth2
2021 年 CNCF 调查:Kubernetes 跨越鸿沟的一年
With a loss of 13.6 billion yuan in three years, can listing revive Weima?
Hamad application layout scheme of hashicopy 01
【SystemVerilog 之 接口】~ Interface
数据库“百亿蓝海”中,每位玩家都能找到一叶扁舟 | C位面对面
Exporting data using mysqldump
Tangzhengrong: CTO is the intersection of business thinking and technical thinking
当开源遇见 KPI,全球化 VS 本土化,开源的理想与现实该如何和解?
浅析分布式系统之体系结构-事务与隔离级别(多对象、多操作)下篇
大道至簡 | 設計 ViT 到底怎麼配置Self-Attention才是最合理的?
[mysql_11] addition, deletion and modification of data processing
MySQL user authority summary [user authorization required]
Hashicopy之nomad应用编排方案04(伸缩及更新一个Job)
Why do I need the public static void main (string[] args) method?
Square and storage box (linear DP)
PowerShell主架构师:我用业余时间开发项目,表现优秀反而被微软降级了
3年亏损136亿,上市能救活威马吗?