当前位置:网站首页>LeetCode-64-最小路径和
LeetCode-64-最小路径和
2022-06-29 15:26:00 【z754916067】
题目

思路
- 一眼好纯好纯的动态规划,没啥意思
- dp[i][j]指从arr[0][0]到arr[i][j]的最小路径
代码
public int minPathSum(int[][] grid) {
int[][] dp = new int[grid.length][grid[0].length];
dp[0][0]=grid[0][0];
//赋初始值
for(int i=1;i<grid.length;i++) dp[i][0]=dp[i-1][0]+grid[i][0];
for(int i=1;i<grid[0].length;i++) dp[0][i]=dp[0][i-1]+grid[0][i];
//每层赋值
for(int i=1;i<grid.length;i++){
for (int j=1;j<grid[0].length;j++){
dp[i][j] = grid[i][j]+Math.min(dp[i-1][j],dp[i][j-1]);
}
}
return dp[grid.length-1][grid[0].length-1];
}
边栏推荐
- JS will have variable promotion and function promotion
- Create an API rapid development platform, awesome!
- . Net program configuration file operation (INI, CFG, config)
- message from server: “Host ‘xxxxxx‘ is blocked because of many connection errors; unblock with ‘m
- Uncover the practice of Baidu intelligent test in the field of automatic test execution
- 14.IP协议-bite
- Render follows, encapsulating a form and adding data to the table
- Kotlin annotation Statement and use
- BioVendor遊離輕鏈(κ和λ)Elisa 試劑盒的化學性質
- Neural network for remote sensing image processing
猜你喜欢

GWD:基于高斯Wasserstein距离的旋转目标检测 | ICML 2021

Google 软件版本经历周期

Lumiprobe deoxyribonucleic acid alkyne DT phosphimide

Flink SQL task taskmanager memory settings

13.TCP-bite

Chapter IX app project test (4) test tools

Take another picture of cloud redis' improvement path

postgresql源码学习(23)—— 事务日志④-日志组装

Lumiprobe click chemistry - non fluorescent alkyne: hexanoic acid STP ester

12.udp protocol -bite
随机推荐
CKS CKA ckad change terminal to remote desktop
Andorid Jetpack Hilt
Summary of recent work
Informatics Olympiad all in one 2061: trapezoidal area
Lumiprobe reactive dye cycloalkyne dye: af488 dbco, 5 isomer
NFS configuring file mapping between two hosts
File common tool class, stream related application (record)
JS will have variable promotion and function promotion
Ink drop typesetting
Basic composition of radar
极化SAR几种成像模式
LeetCode笔记:Biweekly Contest 81
MCS: multivariate random variable polynomial distribution
Solution to the problem that the assembly drawing cannot be recognized after the storage position of SolidWorks part drawing is changed
Northwestern Polytechnic University attacked by overseas e-mail
Lumiprobe click chemistry - non fluorescent alkyne: hexanoic acid STP ester
服务器的数据库连不上了【服务已起、防火墙已关、端口已开、netlent 端口不通】
kotlin 注解声明与使用
Informatics Olympiad all in one 1002: output the second integer
Bash summary online log