|
1 | 1 | package com.fishercoder.solutions;
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * 1289. Minimum Falling Path Sum II |
5 |
| - * |
6 |
| - * Given a square grid of integers arr, a falling path with non-zero shifts is a |
7 |
| - * choice of exactly one element from each row of arr, such that no two elements chosen in adjacent rows are in the same column. |
8 |
| - * Return the minimum sum of a falling path with non-zero shifts. |
9 |
| - * |
10 |
| - * Example 1: |
11 |
| - * Input: arr = [[1,2,3],[4,5,6],[7,8,9]] |
12 |
| - * Output: 13 |
13 |
| - * Explanation: |
14 |
| - * The possible falling paths are: |
15 |
| - * [1,5,9], [1,5,7], [1,6,7], [1,6,8], |
16 |
| - * [2,4,8], [2,4,9], [2,6,7], [2,6,8], |
17 |
| - * [3,4,8], [3,4,9], [3,5,7], [3,5,9] |
18 |
| - * The falling path with the smallest sum is [1,5,7], so the answer is 13. |
19 |
| - * |
20 |
| - * Constraints: |
21 |
| - * 1 <= arr.length == arr[i].length <= 200 |
22 |
| - * -99 <= arr[i][j] <= 99 |
23 |
| - * */ |
24 | 3 | public class _1289 {
|
25 | 4 | public static class Solution1 {
|
26 | 5 | public int minFallingPathSum(int[][] arr) {
|
|
0 commit comments