博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[LeetCode]Minimum Path Sum
阅读量:4704 次
发布时间:2019-06-10

本文共 656 字,大约阅读时间需要 2 分钟。

Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.

Note: You can only move either down or right at any point in time.

思考:DP方程:dp[i][j]=grid[i][j]+min(dp[i-1][j],dp[i][j-1])。

class Solution {public:    int minPathSum(vector
> &grid) { // IMPORTANT: Please reset any member data you declared, as // the same Solution instance will be reused for each test case. int m=grid.size(); int n=grid[0].size(); int i,j,ret=0; int **dp=new int*[m]; for(i=0;i

  

转载于:https://www.cnblogs.com/Rosanna/p/3439235.html

你可能感兴趣的文章
【转】IT名企面试:微软笔试题(1)
查看>>
IO流入门-第十章-DataInputStream_DataOutputStream
查看>>
DRF的分页
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
python:open/文件操作
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
tomcat 和MySQL的安装
查看>>
git常用操作
查看>>
京东SSO单点登陆实现分析
查看>>
u-boot启动第一阶段
查看>>
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>
C#中StreamReader读取中文出现乱码
查看>>
使用BufferedReader的时候出现的问题
查看>>
批处理文件中的路径问题
查看>>
hibernate出现No row with the given identifier exists问题
查看>>
为什么wait()和notify()属于Object类
查看>>