> For the complete documentation index, see [llms.txt](https://ondrej-kvasnovsky-2.gitbook.io/algorithms/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ondrej-kvasnovsky-2.gitbook.io/algorithms/interviews/google-leetcode/minimum-path-sum.md).

# Minimum Path Sum

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:**&#x59;ou can only move either down or right at any point in time.

**Example:**

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

## Solution

```
class Solution {
    public int minPathSum(int[][] grid) {

    }
}
```
