首页 > 其他分享 >LeetCode[64]MinimumPathSum

LeetCode[64]MinimumPathSum

时间:2023-08-18 14:36:27浏览次数:50  
标签:int ++ length grid path 64 MinimumPathSum LeetCode dp

Content

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.

 

Example 1:

Input: grid = [[1,3,1],[1,5,1],[4,2,1]]
Output: 7
Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum.

Example 2:

Input: grid = [[1,2,3],[4,5,6]]
Output: 12

 

Constraints:

  • m == grid.length
  • n == grid[i].length
  • 1 <= m, n <= 200
  • 0 <= grid[i][j] <= 200
Related Topics
  • 数组
  • 动态规划
  • 矩阵

  • 标签:int,++,length,grid,path,64,MinimumPathSum,LeetCode,dp
    From: https://www.cnblogs.com/shea24/p/17640410.html
  • 相关文章

    • LeetCode[55]JumpGame
      ContentYouaregivenanintegerarraynums.Youareinitiallypositionedatthearray'sfirstindex,andeachelementinthearrayrepresentsyourmaximumjumplengthatthatposition.Returntrueifyoucanreachthelastindex,orfalseotherwise.......
    • LeetCode[62]UniquePaths
      ContentThereisarobotonanmxngrid.Therobotisinitiallylocatedatthetop-leftcorner(i.e.,grid[0][0]).Therobottriestomovetothebottom-rightcorner(i.e.,grid[m-1][n-1]).Therobotcanonlymoveeitherdownorrightatanypointi......
    • LeetCode[53]MaximumSubarray
      ContentGivenanintegerarraynums,findthesubarraywiththelargestsum,andreturnitssum. Example1:Input:nums=[-2,1,-3,4,-1,2,1,-5,4]Output:6Explanation:Thesubarray[4,-1,2,1]hasthelargestsum6.Example2:Input:nums=[1]Output:......
    • LeetCode[42]TrappingRainWater
      ContentGivennnon-negativeintegersrepresentinganelevationmapwherethewidthofeachbaris1,computehowmuchwateritcantrapafterraining. Example1:Input:height=[0,1,0,2,1,0,1,3,2,1,2,1]Output:6Explanation:Theaboveelevationmap......
    • LeetCode[32]LongestValidParentheses
      ContentGivenastringcontainingjustthecharacters'('and')',returnthelengthofthelongestvalid(well-formed)parenthesessubstring. Example1:Input:s="(()"Output:2Explanation:Thelongestvalidparentheses......
    • LeetCode[10]RegularExpressionMatching
      ContentGivenaninputstrings andapatternp,implementregularexpressionmatchingwithsupportfor'.'and'*'where:'.'Matchesanysinglecharacter.​​​​'*'Matcheszeroormoreoftheprecedingelement.T......
    • zlmediakit源码学习(扩展支持转码H265/H264)
      在zlmediakit源码基础上继续探索扩展支持H265/H264的转码功能。参照上一篇帖子:https://www.cnblogs.com/feixiang-energy/p/17623567.html 作者已经封装好了基于ffmpeg实现的解码、编码、视频图像格式转换、音频重采样等接口,https://gitee.com/xia-chu/ZLMediaKit/blob/feature......
    • 如何实现RTSP推送H.264、RTSP推送H.265(hevc)
      1.rtsp推送流程.主要分两部分:第一部分先发送信令;第二部分发送rtp包。信令流程:1.1先发送OPTIONS,OPTIONS比较常用,就不做详细说明了。1.2发送ANNOUNCE,发送ANNOUNCE主要是把要推送的音视频信息通过sdp格式传给服务器。关于sdp信息如何构造,对于h264请参考rfc6184.h265请参考r......
    • LeetCode 392.判断子序列
      1.题目:给定字符串 s 和 t ,判断 s 是否为 t 的子序列。字符串的一个子序列是原始字符串删除一些(也可以不删除)字符而不改变剩余字符相对位置形成的新字符串。(例如,"ace"是"abcde"的一个子序列,而"aec"不是)。进阶:如果有大量输入的S,称作S1,S2,...,Sk其中k>=10亿,你需要......
    • #yyds干货盘点# LeetCode程序员面试金典:存在重复元素 II
      题目:给你一个整数数组 nums 和一个整数 k ,判断数组中是否存在两个 不同的索引 i 和 j ,满足 nums[i]==nums[j] 且 abs(i-j)<=k 。如果存在,返回 true ;否则,返回 false 。 示例 1:输入:nums=[1,2,3,1],k=3输出:true示例2:输入:nums=[1,0,1,1],k=1输出......