## Solution - $\texttt{dp}[i][j]$ 表示到 $(i,j)$ 的最便宜的价格,对于第一行和第一列其实都是可以固定计算的,之后就可以根据比较行 / 列进行计算。 - 与 [[LeetCode 0062 - Unique Paths]] 和 [[LeetCode 0063 - Unique Paths II]] 相似。 ## Problem ### Problem Statement Given a $m \times n$ grid filled with non-negative numbers, find a path from top left to bottom right, which minimises the sum of all numbers along its path. Note: You can only move either down or right at any point in time. ### Examples #### Example 1 **Input:** $\texttt{grid} = [[1,3,1],[1,5,1],[4,2,1]]$ **Output:** 7 **Explanation:** Because the path $1 \rightarrow 3 \rightarrow 1 \rightarrow 1 \rightarrow 1$ minimises the sum. #### Example 2 **Input:** $\texttt{grid} = [[1,2,3],[4,5,6]]$ **Output:** 12 ### Constraints - $m == \operatorname{grid.length}$ - $n == \operatorname{grid}[i].\operatorname{length}$ - $1 \leq m, n \leq 200$ - $0 \leq \operatorname{grid}[i][j] \leq 200$