当前位置:网站首页>Leetcode-64- minimum path sum
Leetcode-64- minimum path sum
2022-06-29 15:48:00 【z754916067】
subject

Ideas
- A good look at pure good pure dynamic programming , It doesn't mean much.
- dp[i][j] From arr[0][0] To arr[i][j] The smallest path of
Code
public int minPathSum(int[][] grid) {
int[][] dp = new int[grid.length][grid[0].length];
dp[0][0]=grid[0][0];
// Initial value of Fu
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];
// Assignment per layer
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];
}
边栏推荐
- 京东健康回应拟以 3.554 亿美元收购京东资产:与宠物健康产品品类相关
- Flink SQL任务TaskManager内存设置
- MySQL 数据库命名规范.PDF
- el-table-column行按钮防重控制loading
- "Game engine shallow in shallow out" 98 Substancepainer plug-in development
- ImgUtil 图片处理工具类,文字提取,图片水印
- 在shop工程中,实现一个菜单(增删改查)
- File常用工具类, 流相关运用 (记录)
- PostgreSQL source code learning (25) -- transaction log ⑥ - wait for log writing to complete
- CVPR 2022 | 大幅减少零样本学习所需的人工标注,马普所和北邮提出富含视觉信息的类别语义嵌入
猜你喜欢

89. (cesium article) cesium aggregation diagram (custom picture)

雷达基本组成

The way of enterprise transformation and upgrading: digital transformation, thinking first

Andorid Jetpack Hilt

Mingdeyang xilinx-k7-325t/410t core board data manual

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

12.udp protocol -bite

C # learning 1: value type and reference type

关于SQL+NoSQL : NewSQL数据库

What are the advantages of intelligent chat robots? Senior independent station sellers tell you!
随机推荐
12.udp protocol -bite
.NET程序配置文件操作(ini,cfg,config)
Andorid Jetpack Hilt
Dynamically listening for DOM element height changes
Basic composition of radar
2022 OpenVINO DevCon 大揭秘!英特尔携众多合作伙伴深化开发者生态建设,释放AI产业创新潜能
Summary of recent work
Alibaba cloud experience Award: use polardb-x and Flink to build a large real-time data screen
微信公告号 图灵机器人实现智能回复
MySQL开发规范.pdf
《网络是怎么样连接的》读书笔记 - WEB服务端请求和响应(五)
mysql XA 分布式事务
Swoole TCP distributed implementation
Several imaging modes of polarimetric SAR
C#学习二:堆和栈
89.(cesium篇)cesium聚合图(自定义图片)
LeetCode-64-最小路径和
雷达基本组成
微信公告号自动回复使用图灵机器人实现智能回复
LeetCode-1188. Designing finite blocking queues