11[#0931-minimum-falling-path-sum]
2- = 931. Minimum Falling Path Sum
2+ = 931. 下降路径最小和
33
4- { leetcode} /problems/minimum-falling-path-sum/[LeetCode - Minimum Falling Path Sum ^]
4+ https:// leetcode.cn /problems/minimum-falling-path-sum/[LeetCode - 931. 下降路径最小和 ^]
55
6- Given a *square* array of integers `A` , we want the *minimum* sum of a _falling path_ through `A` .
6+ 给你一个 `n x n` 的 *方形* 整数数组 `matrix` ,请你找出并返回通过 `matrix` 的 **下降路径** 的 *最小和* 。
77
8- A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different from the previous row's column by at most one.
8+ *下降路径* 可以从第一行中的任何元素开始,并从每一行中选择一个元素。在下一行选择的元素和当前行所选元素最多相隔一列(即位于正下方或者沿对角线向左或者向右的第一个元素)。具体来说,位置 `( row, col)` 的下一个元素应当是 `( row + 1, col - 1)` 、 `( row + 1, col)` 或者 `( row + 1, col + 1)` 。
99
10-
10+ *示例 1:*
1111
12- *Example 1:*
13-
14- [subs="verbatim,quotes,macros"]
15- ----
16- *Input:* [[1,2,3],[4,5,6],[7,8,9]]
17- *Output:* 12
18- *Explanation:*
19- The possible falling paths are:
20- ----
12+ image::images/0931-01.jpg[{image_attr}]
2113
14+ ....
15+ 输入:matrix = [[2,1,3],[6,5,4],[7,8,9]]
16+ 输出:13
17+ 解释:如图所示,为和最小的两条下降路径
18+ ....
2219
23- * `[1,4,7], [1,4,8], [1,5,7], [1,5,8], [1,5,9]`
24- * `[2,4,7], [2,4,8], [2,5,7], [2,5,8], [2,5,9], [2,6,8], [2,6,9]`
25- * `[3,5,7], [3,5,8], [3,5,9], [3,6,8], [3,6,9]`
20+ *示例 2:*
2621
22+ image::images/0931-02.jpg[{image_attr}]
2723
28- The falling path with the smallest sum is `[1,4,7]`, so the answer is `12`.
24+ ....
25+ 输入:matrix = [[-19,57],[-40,-5]]
26+ 输出:-59
27+ 解释:如图所示,为和最小的下降路径
28+ ....
2929
30-
30+ *提示:*
3131
32- *Note:*
32+ * `n == matrix.length == matrix[i].length`
33+ * `+1 <= n <= 100+`
34+ * `+-100 <= matrix[i][j] <= 100+`
3335
3436
35- * `1 <= A.length == A[0].length <= 100`
36- * `-100 <= A[i][j] <= 100`
37-
3837== 思路分析
3938
39+
4040[[src-0931]]
4141[tabs]
4242====
@@ -49,14 +49,14 @@ include::{sourcedir}/_0931_MinimumFallingPathSum.java[tag=answer]
4949----
5050--
5151
52- // 二刷::
53- // +
54- // --
55- // [{java_src_attr}]
56- // ----
57- // include::{sourcedir}/_0931_MinimumFallingPathSum_2.java[tag=answer]
58- // ----
59- // --
52+ 二刷::
53+ +
54+ --
55+ [{java_src_attr}]
56+ ----
57+ include::{sourcedir}/_0931_MinimumFallingPathSum_2.java[tag=answer]
58+ ----
59+ --
6060====
6161
6262== 参考资料
0 commit comments