#64
Minimum Path Sum
pupil · 585 · lc medium +29 · verified · 67.9% accepted · 13,624 likes · top 74%
Description
In m x n grid of non-negative integers, find a path from top-left to bottom-right — moving only right or down — that minimizes the total sum of values along the path.
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
Code
1
2
3