931. Minimum Falling Path Sum Medium

@problem@discussion
#Array#Dynamic Programming#Matrix



1/**
2 * [931] Minimum Falling Path Sum
3 *
4 * Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix.
5 * A falling path starts at any element in the first row and chooses the element in the next row that is either directly below or diagonally left/right. Specifically, the next element from position (row, col) will be (row + 1, col - 1), (row + 1, col), or (row + 1, col + 1).
6 *  
7 * Example 1:
8 * <img alt="" src="https://assets.leetcode.com/uploads/2021/11/03/failing1-grid.jpg" style="width: 499px; height: 500px;" />
9 * Input: matrix = [[2,1,3],[6,5,4],[7,8,9]]
10 * Output: 13
11 * Explanation: There are two falling paths with a minimum sum as shown.
12 * 
13 * Example 2:
14 * <img alt="" src="https://assets.leetcode.com/uploads/2021/11/03/failing2-grid.jpg" style="width: 164px; height: 365px;" />
15 * Input: matrix = [[-19,57],[-40,-5]]
16 * Output: -59
17 * Explanation: The falling path with a minimum sum is shown.
18 * 
19 *  
20 * Constraints:
21 * 
22 * 	n == matrix.length == matrix[i].length
23 * 	1 <= n <= 100
24 * 	-100 <= matrix[i][j] <= 100
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/minimum-falling-path-sum/
30// discuss: https://leetcode.com/problems/minimum-falling-path-sum/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn min_falling_path_sum(matrix: Vec<Vec<i32>>) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_931() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.